Files
fizzy/db/migrate/20250224152047_create_subscriptions.rb
T
Kevin McConnell 2b8d41a752 Start with subscriptions on for everyone
To prevent people missing a notification they care about when we ship
the subscriptions feature, we'll start out with everything toggled on
(which matches the previous behaviour). People can then opt out as they
like.
2025-02-27 10:42:19 +00:00

19 lines
644 B
Ruby

class CreateSubscriptions < ActiveRecord::Migration[8.1]
def change
create_table :subscriptions do |t|
t.references :subscribable, polymorphic: true, null: false, index: true
t.references :user, null: false, foreign_key: true
t.timestamps
t.index [ :subscribable_type, :subscribable_id, :user_id ], unique: true
end
# Subscribe everyone to their current buckets to start with
execute "
insert into subscriptions (subscribable_type, subscribable_id, user_id, created_at, updated_at)
select 'Bucket', bucket_id, user_id, current_timestamp, current_timestamp from accesses;
"
end
end