blue-twilight/database/migrations/2016_09_08_215424_remove_upload_tables.php

59 lines
1.6 KiB
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RemoveUploadTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('upload_photos');
Schema::dropIfExists('uploads');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::create('uploads', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('album_id');
$table->boolean('is_completed');
$table->boolean('is_processing');
$table->integer('number_photos')->default(0);
$table->integer('number_successful')->default(0);
$table->integer('number_failed')->default(0);
$table->boolean('is_ready');
$table->timestamps();
$table->foreign('album_id')
->references('id')->on('albums')
->onDelete('cascade');
});
Schema::create('upload_photos', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('upload_id');
$table->unsignedBigInteger('photo_id');
$table->boolean('is_ready');
$table->timestamps();
$table->foreign('upload_id')
->references('id')->on('uploads')
->onDelete('cascade');
$table->foreign('photo_id')
->references('id')->on('photos')
->onDelete('cascade');
});
}
}