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.
This commit is contained in:
Mike Dalessio
2025-11-13 21:48:30 -05:00
parent 5a7f08067a
commit fe6df7085f
42 changed files with 311 additions and 49 deletions
+4
View File
@@ -1,19 +1,23 @@
writebook_david:
id: <%= ActiveRecord::FixtureSet.identify("writebook_david", :uuid) %>
account: 37s_uuid
board: writebook_uuid
user: david_uuid
writebook_jz:
id: <%= ActiveRecord::FixtureSet.identify("writebook_jz", :uuid) %>
account: 37s_uuid
board: writebook_uuid
user: jz_uuid
writebook_kevin:
id: <%= ActiveRecord::FixtureSet.identify("writebook_kevin", :uuid) %>
account: 37s_uuid
board: writebook_uuid
user: kevin_uuid
private_kevin:
id: <%= ActiveRecord::FixtureSet.identify("private_kevin", :uuid) %>
account: 37s_uuid
board: private_uuid
user: kevin_uuid
+3 -15
View File
@@ -1,32 +1,20 @@
logo_agreement_jz:
id: <%= ActiveRecord::FixtureSet.identify("logo_agreement_jz_rich_text", :uuid) %>
account: 37s_uuid
record: logo_agreement_jz_uuid (Comment)
name: body
body: I agree.
logo_agreement_kevin:
id: <%= ActiveRecord::FixtureSet.identify("logo_agreement_kevin_rich_text", :uuid) %>
account: 37s_uuid
record: logo_agreement_kevin_uuid (Comment)
name: body
body: Same, let's do it.
layout_overflowing_david:
id: <%= ActiveRecord::FixtureSet.identify("layout_overflowing_david_rich_text", :uuid) %>
account: 37s_uuid
record: layout_overflowing_david_uuid (Comment)
name: body
body: The text is overflowing the container.
kevins_conversation_question:
record: kevins_question (Conversation::Message)
name: content
body: "Who is on a hot-streak?"
kevins_conversation_answer:
record: kevins_answer (Conversation::Message)
name: content
body: "<b>David</b> is on a hot-streak. He has recently added many cards to Writebook."
davids_conversation_question:
record: davids_question (Conversation::Message)
name: content
body: "What is the meaning of life, the Universe, and everything else?"
+3
View File
@@ -1,5 +1,6 @@
logo_jz:
id: <%= ActiveRecord::FixtureSet.identify("logo_jz", :uuid) %>
account: 37s_uuid
assigner: david_uuid
assignee: jz_uuid
card: logo_uuid
@@ -7,6 +8,7 @@ logo_jz:
logo_kevin:
id: <%= ActiveRecord::FixtureSet.identify("logo_kevin", :uuid) %>
account: 37s_uuid
assigner: david_uuid
assignee: kevin_uuid
card: logo_uuid
@@ -14,6 +16,7 @@ logo_kevin:
layout_jz:
id: <%= ActiveRecord::FixtureSet.identify("layout_jz", :uuid) %>
account: 37s_uuid
assigner: david_uuid
assignee: jz_uuid
card: layout_uuid
+1
View File
@@ -1,3 +1,4 @@
logo:
id: <%= ActiveRecord::FixtureSet.identify("logo_engagement", :uuid) %>
account: 37s_uuid
card: logo_uuid
+1
View File
@@ -1,3 +1,4 @@
logo:
id: <%= ActiveRecord::FixtureSet.identify("logo_goldness", :uuid) %>
account: 37s_uuid
card: logo_uuid
+2 -1
View File
@@ -1,4 +1,5 @@
shipping:
id: <%= ActiveRecord::FixtureSet.identify("shipping_closure", :uuid) %>
account: 37s_uuid
card: shipping_uuid
user: kevin_uuid
user: kevin_uuid
+3
View File
@@ -1,14 +1,17 @@
37s_account:
id: <%= ActiveRecord::FixtureSet.identify("37s_account", :uuid) %>
account: 37s_uuid
container: 37s_uuid (Account)
auto_postpone_period: <%= 30.days.to_i %>
writebook_board:
id: <%= ActiveRecord::FixtureSet.identify("writebook_board", :uuid) %>
account: 37s_uuid
container: writebook_uuid (Board)
auto_postpone_period: <%= 90.days.to_i %>
private_board:
id: <%= ActiveRecord::FixtureSet.identify("private_board", :uuid) %>
account: 37s_uuid
container: private_uuid (Board)
auto_postpone_period: <%= 30.days.to_i %>
+2
View File
@@ -1,11 +1,13 @@
logo_card_david_mention_by_jz:
id: <%= ActiveRecord::FixtureSet.identify("logo_card_david_mention_by_jz", :uuid) %>
account: 37s_uuid
source: logo_uuid (Card)
mentioner: jz_uuid
mentionee: david_uuid
logo_comment_david_mention_by_jz:
id: <%= ActiveRecord::FixtureSet.identify("logo_comment_david_mention_by_jz", :uuid) %>
account: 37s_uuid
source: logo_agreement_jz_uuid (Comment)
mentioner: jz_uuid
mentionee: david_uuid
+3 -1
View File
@@ -1,9 +1,11 @@
logo_kevin:
id: <%= ActiveRecord::FixtureSet.identify("logo_kevin_pin", :uuid) %>
account: 37s_uuid
card: logo_uuid
user: kevin_uuid
shipping_kevin:
id: <%= ActiveRecord::FixtureSet.identify("shipping_kevin_pin", :uuid) %>
account: 37s_uuid
card: shipping_uuid
user: kevin_uuid
user: kevin_uuid
+2
View File
@@ -1,11 +1,13 @@
kevin:
id: <%= ActiveRecord::FixtureSet.identify("kevin_reaction", :uuid) %>
account: 37s_uuid
content: "👍"
comment: logo_agreement_jz_uuid
reacter: kevin_uuid
david:
id: <%= ActiveRecord::FixtureSet.identify("david_reaction", :uuid) %>
account: 37s_uuid
content: "👍"
comment: logo_agreement_jz_uuid
reacter: david_uuid
+4
View File
@@ -1,19 +1,23 @@
logo_web:
id: <%= ActiveRecord::FixtureSet.identify("logo_web_tagging", :uuid) %>
account: 37s_uuid
card: logo_uuid
tag: web_uuid
layout_web:
id: <%= ActiveRecord::FixtureSet.identify("layout_web_tagging", :uuid) %>
account: 37s_uuid
card: layout_uuid
tag: web_uuid
layout_mobile:
id: <%= ActiveRecord::FixtureSet.identify("layout_mobile_tagging", :uuid) %>
account: 37s_uuid
card: layout_uuid
tag: mobile_uuid
text_mobile:
id: <%= ActiveRecord::FixtureSet.identify("text_mobile_tagging", :uuid) %>
account: 37s_uuid
card: text_uuid
tag: mobile_uuid
+4
View File
@@ -3,20 +3,24 @@ _fixture:
david_settings:
id: <%= ActiveRecord::FixtureSet.identify("david_settings", :uuid) %>
account: 37s_uuid
user: david_uuid
bundle_email_frequency: never
jz_settings:
id: <%= ActiveRecord::FixtureSet.identify("jz_settings", :uuid) %>
account: 37s_uuid
user: jz_uuid
bundle_email_frequency: never
kevin_settings:
id: <%= ActiveRecord::FixtureSet.identify("kevin_settings", :uuid) %>
account: 37s_uuid
user: kevin_uuid
bundle_email_frequency: never
system_settings:
id: <%= ActiveRecord::FixtureSet.identify("system_settings", :uuid) %>
account: 37s_uuid
user: system_uuid
bundle_email_frequency: never
+9
View File
@@ -1,53 +1,62 @@
logo_david:
id: <%= ActiveRecord::FixtureSet.identify("logo_david_watch", :uuid) %>
account: 37s_uuid
card: logo_uuid
user: david_uuid
watching: true
logo_kevin:
id: <%= ActiveRecord::FixtureSet.identify("logo_kevin_watch", :uuid) %>
account: 37s_uuid
card: logo_uuid
user: kevin_uuid
watching: true
layout_david:
id: <%= ActiveRecord::FixtureSet.identify("layout_david_watch", :uuid) %>
account: 37s_uuid
card: layout_uuid
user: david_uuid
watching: true
layout_kevin:
id: <%= ActiveRecord::FixtureSet.identify("layout_kevin_watch", :uuid) %>
account: 37s_uuid
card: layout_uuid
user: kevin_uuid
watching: true
text_david:
id: <%= ActiveRecord::FixtureSet.identify("text_david_watch", :uuid) %>
account: 37s_uuid
card: text_uuid
user: david_uuid
watching: true
text_jz:
id: <%= ActiveRecord::FixtureSet.identify("text_jz_watch", :uuid) %>
account: 37s_uuid
card: text_uuid
user: jz_uuid
watching: true
shipping_david:
id: <%= ActiveRecord::FixtureSet.identify("shipping_david_watch", :uuid) %>
account: 37s_uuid
card: shipping_uuid
user: david_uuid
watching: true
shipping_jz:
id: <%= ActiveRecord::FixtureSet.identify("shipping_jz_watch", :uuid) %>
account: 37s_uuid
card: shipping_uuid
user: jz_uuid
watching: true
shipping_kevin:
id: <%= ActiveRecord::FixtureSet.identify("shipping_kevin_watch", :uuid) %>
account: 37s_uuid
card: shipping_uuid
user: kevin_uuid
watching: true
+2
View File
@@ -2,12 +2,14 @@
active_webhook_tracker:
id: <%= ActiveRecord::FixtureSet.identify("active_webhook_tracker", :uuid) %>
account: 37s_uuid
webhook: active_uuid
consecutive_failures_count: 1
first_failure_at: <%= 1.hour.ago %>
inactive_webhook_tracker:
id: <%= ActiveRecord::FixtureSet.identify("inactive_webhook_tracker", :uuid) %>
account: 37s_uuid
webhook: inactive_uuid
consecutive_failures_count: 1
first_failure_at: <%= 1.hour.ago %>
+5
View File
@@ -2,6 +2,7 @@
successfully_completed:
id: <%= ActiveRecord::FixtureSet.identify("successfully_completed_delivery", :uuid) %>
account: 37s_uuid
webhook: active_uuid
event: logo_published_uuid
state: completed
@@ -11,6 +12,7 @@ successfully_completed:
unsuccessfully_completed:
id: <%= ActiveRecord::FixtureSet.identify("unsuccessfully_completed_delivery", :uuid) %>
account: 37s_uuid
webhook: active_uuid
event: logo_assignment_jz_uuid
state: completed
@@ -20,6 +22,7 @@ unsuccessfully_completed:
errored:
id: <%= ActiveRecord::FixtureSet.identify("errored_delivery", :uuid) %>
account: 37s_uuid
webhook: active_uuid
event: layout_published_uuid
state: errored
@@ -29,6 +32,7 @@ errored:
pending:
id: <%= ActiveRecord::FixtureSet.identify("pending_delivery", :uuid) %>
account: 37s_uuid
webhook: active_uuid
event: shipping_closed_uuid
state: pending
@@ -38,6 +42,7 @@ pending:
in_progress:
id: <%= ActiveRecord::FixtureSet.identify("in_progress_delivery", :uuid) %>
account: 37s_uuid
webhook: active_uuid
event: logo_assignment_km_uuid
state: in_progress