diff --git a/db/migrations/2020_09_27_000000_add_timestamps_to_questions.php b/db/migrations/2020_09_27_000000_add_timestamps_to_questions.php index 6f751a7c..0114bfde 100644 --- a/db/migrations/2020_09_27_000000_add_timestamps_to_questions.php +++ b/db/migrations/2020_09_27_000000_add_timestamps_to_questions.php @@ -2,7 +2,9 @@ namespace Engelsystem\Migrations; +use Carbon\Carbon; use Engelsystem\Database\Migration\Migration; +use Engelsystem\Models\Question; use Illuminate\Database\Schema\Blueprint; class AddTimestampsToQuestions extends Migration @@ -18,6 +20,17 @@ class AddTimestampsToQuestions extends Migration $table->timestamp('answered_at')->after('answerer_id')->nullable(); $table->timestamps(); }); + + $now = Carbon::now(); + Question::query()->update([ + 'created_at' => $now, + 'updated_at' => $now, + ]); + Question::query() + ->whereNotNull('answerer_id') + ->update([ + 'answered_at' => $now, + ]); } /**