49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::table('accounts', function (Blueprint $table) {
|
||
|
$table->datetime('created_at')->nullable()->after('id');
|
||
|
$table->datetime('updated_at')->nullable()->after('created_at');
|
||
|
$table->date('expire_at')->nullable()->after('updated_at');
|
||
|
});
|
||
|
|
||
|
// Convert our dates
|
||
|
foreach (\App\Models\Account::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
|
||
|
if ($o->date_orig)
|
||
|
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
|
||
|
if ($o->date_last)
|
||
|
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
|
||
|
if ($o->date_expire)
|
||
|
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire);
|
||
|
|
||
|
$o->save();
|
||
|
}
|
||
|
|
||
|
Schema::table('accounts', function (Blueprint $table) {
|
||
|
$table->dropColumn(['date_orig','date_last','date_expire']);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
abort(500,'Cant go back');
|
||
|
}
|
||
|
};
|