Files
fizzy/db/migrate/20251113160907_add_missing_account_id_columns.rb
T
Mike Dalessio fe6df7085f Finish the rollout of account_id to all core data models
Schema:
- add account_id to tables it was missing from
- make account_id a required column everywhere
- add [account_id] indexes, or add `account_id` to existing indices

Models:
- add `belongs_to :account` to all models (default to using a domain
  model's account whenever possible)
- add account_id in all the necessary fixtures
- add account_id to insert_all hashes
- pass account_id to a few initialize calls

Miscellaneous:
- update the import script to set account_id

Note that I'm not adding account_id to the join tables primarily
because I couldn't think of an easy way to populate it without making
it a full Join model, and that was more work than I have time to take
on right now.
2025-11-17 09:12:40 -05:00

55 lines
992 B
Ruby

class AddMissingAccountIdColumns < ActiveRecord::Migration[8.2]
MISSING_TABLES= %w[
accesses
assignments
board_publications
card_activity_spikes
card_engagements
card_goldnesses
card_not_nows
closures
entropies
mentions
pins
reactions
search_queries
taggings
user_settings
watches
webhook_delinquency_trackers
webhook_deliveries
action_text_rich_texts
active_storage_attachments
active_storage_blobs
active_storage_variant_records
]
NOT_REQUIRED_TABLES = %w[
account_join_codes
boards
cards
columns
comments
events
filters
notification_bundles
notifications
push_subscriptions
steps
tags
users
webhooks
]
def change
MISSING_TABLES.each do |table|
add_column table, "account_id", :uuid, null: false
end
NOT_REQUIRED_TABLES.each do |table|
change_column table, "account_id", :uuid, null: false
end
end
end