From b41cf7f7e474f12d93887e9b7297e73608623b8a Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Mon, 2 Nov 2026 10:07:36 +0000 Subject: [PATCH] DNM: possible automatic_expiry_backfill --- ...11_01_153231_automatic_expiry_backfill.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 database/migrations/2026_11_01_153231_automatic_expiry_backfill.php diff --git a/database/migrations/2026_11_01_153231_automatic_expiry_backfill.php b/database/migrations/2026_11_01_153231_automatic_expiry_backfill.php new file mode 100644 index 00000000..dbebe93e --- /dev/null +++ b/database/migrations/2026_11_01_153231_automatic_expiry_backfill.php @@ -0,0 +1,40 @@ +leftJoin('wiki_suspensions', 'wikis.id', '=', 'wiki_suspensions.wiki_id') + ->whereNull('wiki_id') + ->orderBy('wikis.id') + ->select('wikis.id', 'wikis.created_at') + ->chunkById(100, fn ($wikis) => DB::table('policy_acceptances')->insert( + $wikis->map(fn ($wiki) => [ + 'user_id' => $wiki->id, + 'accepted_at' => $wiki->created_at, + 'created_at' => $timestamp, + 'updated_at' => $timestamp, + ])->all() + ), + 'users.id', 'id'); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + throw new RuntimeException("The 'down' method is not supported"); + } +};