Internal optimisations and additional flags for Photo/Video
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddOverrideKeepAttributes extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('photo', function (Blueprint $table) {
|
||||
$table->dateTime('created')->nullable();
|
||||
$table->dateTime('created_manual')->nullable();
|
||||
$table->boolean('ignore_duplicate')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dateTime('created')->nullable();
|
||||
$table->dateTime('created_manual')->nullable();
|
||||
$table->boolean('ignore_duplicate')->nullable();
|
||||
});
|
||||
|
||||
\App\Models\Photo::each(function($o) {
|
||||
$o->created = $o->date_created;
|
||||
$o->date_created = NULL;
|
||||
$o->save();
|
||||
});
|
||||
|
||||
\App\Models\Video::each(function($o) {
|
||||
$o->created = $o->date_created;
|
||||
$o->date_created = NULL;
|
||||
$o->save();
|
||||
});
|
||||
|
||||
Schema::table('photo', function (Blueprint $table) {
|
||||
$table->dropColumn('date_created');
|
||||
});
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn('date_created');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('photos', function (Blueprint $table) {
|
||||
$table->integer('date_created')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->integer('date_created')->nullable();
|
||||
});
|
||||
|
||||
\App\Models\Photo::each(function($o) {
|
||||
$o->date_created = $o->created;
|
||||
$o->created = NULL;
|
||||
$o->save();
|
||||
});
|
||||
|
||||
\App\Models\Video::each(function($o) {
|
||||
$o->date_created = $o->created;
|
||||
$o->created = NULL;
|
||||
$o->save();
|
||||
});
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn(['created','created_manual','ignore_duplicate']);
|
||||
});
|
||||
|
||||
Schema::table('photo', function (Blueprint $table) {
|
||||
$table->dropColumn(['created','created_manual','ignore_duplicate']);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user