diff options
Diffstat (limited to 'database/migrations/2020_03_05_162010_create_calendar.php')
| -rw-r--r-- | database/migrations/2020_03_05_162010_create_calendar.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/database/migrations/2020_03_05_162010_create_calendar.php b/database/migrations/2020_03_05_162010_create_calendar.php new file mode 100644 index 0000000..3a6cb8f --- /dev/null +++ b/database/migrations/2020_03_05_162010_create_calendar.php @@ -0,0 +1,52 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateCalendar extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('calendar', function (Blueprint $table) { + $table->bigIncrements('id'); + + $table->unsignedBigInteger('mal_id')->default(0); + $table->unsignedBigInteger('user_id')->default(0); + + $table->string('username')->default(''); + $table->timestamp('airing_at'); + $table->integer('duration')->default('20'); + $table->integer('episode')->default(0); + $table->integer('episodes_watched')->default(0)->nullable(); + $table->integer('episodes_complete')->default(0)->nullable(); + $table->float('score')->default(0)->nullable(); + $table->integer('score_user')->default(0)->nullable(); + $table->string('mal_url')->default(''); + $table->string('title')->default(''); + + $table->foreign('mal_id')->references('mal_id')->on('anime'); + $table->foreign('user_id')->references('id')->on('malusers'); + + $table->unique(['mal_id', 'user_id', 'airing_at']); + $table->unique(['mal_id', 'user_id', 'episode']); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('calendar'); + } +} |
