Internal optimisations and additional flags for Photo/Video

This commit is contained in:
Deon George
2020-01-05 00:28:00 +11:00
parent 93364ab53a
commit 1ffc2d994e
19 changed files with 402 additions and 279 deletions

View File

@@ -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']);
});
}
}