From cc212d681e26a96bfddc638222a869acf18fd894 Mon Sep 17 00:00:00 2001 From: Douglas Berkley Date: Thu, 11 Jun 2026 00:07:31 +0900 Subject: [PATCH] updated copilot sql suggestion --- ...fill_email_prediction_missing_for_users.rb | 22 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20260611000001_backfill_email_prediction_missing_for_users.rb diff --git a/db/migrate/20260611000001_backfill_email_prediction_missing_for_users.rb b/db/migrate/20260611000001_backfill_email_prediction_missing_for_users.rb new file mode 100644 index 0000000..5da0e5e --- /dev/null +++ b/db/migrate/20260611000001_backfill_email_prediction_missing_for_users.rb @@ -0,0 +1,22 @@ +class BackfillEmailPredictionMissingForUsers < ActiveRecord::Migration[6.1] + def up + execute <<~SQL + UPDATE users + SET notifications = jsonb_set( + jsonb_set( + COALESCE(notifications, '{}'::jsonb), + '{email}', + COALESCE(notifications->'email', '{}'::jsonb) + ), + '{email,prediction_missing}', + 'true'::jsonb + ) + WHERE notifications IS NULL + OR notifications->'email'->>'prediction_missing' IS NULL + SQL + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index 9143af4..afa8c70 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2026_06_10_144543) do +ActiveRecord::Schema.define(version: 2026_06_11_000001) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements"