Questions: Add current timestamp on migration

This commit is contained in:
Igor Scheller 2020-09-27 23:42:39 +02:00
parent 6c177d5173
commit dbf3737170
1 changed files with 13 additions and 0 deletions

View File

@ -2,7 +2,9 @@
namespace Engelsystem\Migrations; namespace Engelsystem\Migrations;
use Carbon\Carbon;
use Engelsystem\Database\Migration\Migration; use Engelsystem\Database\Migration\Migration;
use Engelsystem\Models\Question;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
class AddTimestampsToQuestions extends Migration class AddTimestampsToQuestions extends Migration
@ -18,6 +20,17 @@ class AddTimestampsToQuestions extends Migration
$table->timestamp('answered_at')->after('answerer_id')->nullable(); $table->timestamp('answered_at')->after('answerer_id')->nullable();
$table->timestamps(); $table->timestamps();
}); });
$now = Carbon::now();
Question::query()->update([
'created_at' => $now,
'updated_at' => $now,
]);
Question::query()
->whereNotNull('answerer_id')
->update([
'answered_at' => $now,
]);
} }
/** /**