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
+1
View File
@@ -1,4 +1,5 @@
class Access < ApplicationRecord
belongs_to :account, default: -> { user.account }
belongs_to :board, touch: true
belongs_to :user, touch: true
+4
View File
@@ -24,4 +24,8 @@ class Account < ApplicationRecord
def slug
"/#{external_account_id}"
end
def account
self
end
end
+1 -1
View File
@@ -5,6 +5,6 @@ module Account::Entropic
included do
has_one :entropy, as: :container, dependent: :destroy
after_create -> { create_entropy!(auto_postpone_period: DEFAULT_ENTROPY_PERIOD) }
after_create -> { create_entropy!(auto_postpone_period: DEFAULT_ENTROPY_PERIOD, account: self) }
end
end
+1
View File
@@ -1,4 +1,5 @@
class Assignment < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, touch: true
belongs_to :assignee, class_name: "User"
+1 -1
View File
@@ -11,7 +11,7 @@ module Board::Accessible
end
def grant_to(users)
Access.insert_all Array(users).collect { |user| { id: ActiveRecord::Type::Uuid.generate, board_id: proxy_association.owner.id, user_id: user.id } }
Access.insert_all Array(users).collect { |user| { id: ActiveRecord::Type::Uuid.generate, board_id: proxy_association.owner.id, user_id: user.id, account_id: proxy_association.owner.account.id } }
end
def revoke_from(users)
+1
View File
@@ -1,4 +1,5 @@
class Board::Publication < ApplicationRecord
belongs_to :account, default: -> { board.account }
belongs_to :board
has_secure_token :key
+1
View File
@@ -1,3 +1,4 @@
class Card::ActivitySpike < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, touch: true
end
+1
View File
@@ -1,4 +1,5 @@
class Card::Engagement < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, class_name: "::Card", touch: true
validates :status, presence: true, inclusion: { in: %w[doing on_deck] }
+1
View File
@@ -1,3 +1,4 @@
class Card::Goldness < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, touch: true
end
+1
View File
@@ -1,4 +1,5 @@
class Card::NotNow < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, class_name: "::Card", touch: true
belongs_to :user, optional: true
end
+1
View File
@@ -1,4 +1,5 @@
class Closure < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :card, touch: true
belongs_to :user, optional: true
end
+1
View File
@@ -1,4 +1,5 @@
class Entropy < ApplicationRecord
belongs_to :account, default: -> { container.account }
belongs_to :container, polymorphic: true
after_commit -> { container.cards.touch_all }
+1
View File
@@ -1,6 +1,7 @@
class Mention < ApplicationRecord
include Notifiable
belongs_to :account, default: -> { source.account }
belongs_to :source, polymorphic: true
belongs_to :mentioner, class_name: "User"
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
+1
View File
@@ -1,4 +1,5 @@
class Pin < ApplicationRecord
belongs_to :account, default: -> { user.account }
belongs_to :card
belongs_to :user
+1
View File
@@ -1,4 +1,5 @@
class Reaction < ApplicationRecord
belongs_to :account, default: -> { comment.account }
belongs_to :comment, touch: true
belongs_to :reacter, class_name: "User", default: -> { Current.user }
+3
View File
@@ -1,4 +1,7 @@
class Search::Query < ApplicationRecord
belongs_to :account, default: -> { user&.account || Current.account }
belongs_to :user, optional: true
validates :terms, presence: true
before_validation :sanitize_terms
+1
View File
@@ -1,4 +1,5 @@
class Tagging < ApplicationRecord
belongs_to :account, default: -> { card.account }
belongs_to :tag
belongs_to :card, touch: true
end
+1 -1
View File
@@ -12,6 +12,6 @@ module User::Accessor
private
def grant_access_to_boards
Access.insert_all account.boards.all_access.pluck(:id).collect { |board_id| { id: ActiveRecord::Type::Uuid.generate, board_id: board_id, user_id: id } }
Access.insert_all account.boards.all_access.pluck(:id).collect { |board_id| { id: ActiveRecord::Type::Uuid.generate, board_id: board_id, user_id: id, account_id: account.id } }
end
end
+1
View File
@@ -1,4 +1,5 @@
class User::Settings < ApplicationRecord
belongs_to :account, default: -> { user.account }
belongs_to :user
enum :bundle_email_frequency, %i[ never every_few_hours daily weekly ],
+1
View File
@@ -1,4 +1,5 @@
class Watch < ApplicationRecord
belongs_to :account, default: -> { user.account }
belongs_to :user
belongs_to :card, touch: true
@@ -2,6 +2,7 @@ class Webhook::DelinquencyTracker < ApplicationRecord
DELINQUENCY_THRESHOLD = 10
DELINQUENCY_DURATION = 1.hour
belongs_to :account, default: -> { webhook.account }
belongs_to :webhook
def record_delivery_of(delivery)
+1
View File
@@ -10,6 +10,7 @@ class Webhook::Delivery < ApplicationRecord
IPAddr.new("0.0.0.0/8")
].freeze
belongs_to :account, default: -> { webhook.account }
belongs_to :webhook
belongs_to :event
@@ -1,7 +1,14 @@
# Inject UUID primary key support into Rails framework models
Rails.application.config.to_prepare do
ActionText::RichText.attribute :id, :uuid, default: -> { ActiveRecord::Type::Uuid.generate }
ActionText::RichText.belongs_to :account, default: -> { record.account }
ActiveStorage::Attachment.attribute :id, :uuid, default: -> { ActiveRecord::Type::Uuid.generate }
ActiveStorage::Attachment.belongs_to :account, default: -> { record.account }
ActiveStorage::Blob.attribute :id, :uuid, default: -> { ActiveRecord::Type::Uuid.generate }
ActiveStorage::Blob.belongs_to :account, default: -> { Current.account }
ActiveStorage::VariantRecord.attribute :id, :uuid, default: -> { ActiveRecord::Type::Uuid.generate }
ActiveStorage::VariantRecord.belongs_to :account, default: -> { blob.account }
end
@@ -0,0 +1,54 @@
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
@@ -0,0 +1,91 @@
class EnsureAccountIdIndex < ActiveRecord::Migration[8.2]
def change
remove_index :accesses, :accessed_at
add_index :accesses, [:account_id, :accessed_at]
remove_index :account_join_codes, :code
add_index :account_join_codes, [:account_id, :code], unique: true
add_index :assignments, :account_id
remove_index :board_publications, :key
add_index :board_publications, [:account_id, :key]
add_index :boards, :account_id
add_index :card_activity_spikes, :account_id
remove_index :card_engagements, :status
add_index :card_engagements, [:account_id, :status]
add_index :card_goldnesses, :account_id
add_index :card_not_nows, :account_id
remove_index :cards, [:last_active_at, :status]
add_index :cards, [:account_id, :last_active_at, :status]
add_index :closures, :account_id
add_index :columns, :account_id
add_index :comments, :account_id
add_index :entropies, :account_id
remove_index :events, :action
add_index :events, [:account_id, :action]
add_index :filters, :account_id
add_index :mentions, :account_id
add_index :notification_bundles, :account_id
add_index :notifications, :account_id
add_index :pins, :account_id
add_index :push_subscriptions, :account_id
remove_index :push_subscriptions, :endpoint # duplicative because we always query [user_id, endpoint]
remove_index :push_subscriptions, [:endpoint, :p256dh_key, :auth_key] # duplicative and not necessary
remove_index :push_subscriptions, :user_agent # not necessary
remove_index :push_subscriptions, :user_id # duplicative of [user_id, endpoint]
add_index :reactions, :account_id
add_index :search_queries, :account_id
add_index :steps, :account_id
add_index :taggings, :account_id
remove_index :tags, :title
add_index :tags, [:account_id, :title], unique: true
add_index :user_settings, :account_id
remove_index :users, :role
add_index :users, [:account_id, :role]
add_index :watches, :account_id
add_index :webhook_delinquency_trackers, :account_id
add_index :webhook_deliveries, :account_id
# For webhooks, I'm making an additional change to collapse board_id and subscribed_actions into
# a single index, since Triggerable only queries for `subscribed_actions` in conjunction with
# `board_id`.
add_index :webhooks, :account_id
remove_index :webhooks, :subscribed_actions
add_index :webhooks, [:board_id, :subscribed_actions], length: { subscribed_actions: 255 }
remove_index :webhooks, :board_id
# Rails models
add_index :action_text_rich_texts, :account_id
add_index :active_storage_attachments, :account_id
add_index :active_storage_blobs, :account_id
add_index :active_storage_variant_records, :account_id
end
end
Generated
+74 -29
View File
@@ -10,28 +10,29 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
ActiveRecord::Schema[8.2].define(version: 2025_11_13_163145) do
create_table "accesses", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.datetime "accessed_at"
t.uuid "account_id", null: false
t.uuid "board_id", null: false
t.datetime "created_at", null: false
t.string "involvement", default: "access_only", null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["accessed_at"], name: "index_accesses_on_accessed_at", order: :desc
t.index ["account_id", "accessed_at"], name: "index_accesses_on_account_id_and_accessed_at"
t.index ["board_id", "user_id"], name: "index_accesses_on_board_id_and_user_id", unique: true
t.index ["board_id"], name: "index_accesses_on_board_id"
t.index ["user_id"], name: "index_accesses_on_user_id"
end
create_table "account_join_codes", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.string "code", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "usage_count", default: 0, null: false
t.integer "usage_limit", default: 10, null: false
t.index ["code"], name: "index_account_join_codes_on_code", unique: true
t.index ["account_id", "code"], name: "index_account_join_codes_on_account_id_and_code", unique: true
end
create_table "accounts", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
@@ -44,26 +45,31 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "action_text_rich_texts", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.text "body", size: :long
t.datetime "created_at", null: false
t.string "name", null: false
t.uuid "record_id", null: false
t.string "record_type", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_action_text_rich_texts_on_account_id"
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end
create_table "active_storage_attachments", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "blob_id", null: false
t.datetime "created_at", null: false
t.string "name", null: false
t.uuid "record_id", null: false
t.string "record_type", null: false
t.index ["account_id"], name: "index_active_storage_attachments_on_account_id"
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.string "content_type"
@@ -72,12 +78,15 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.string "key", null: false
t.text "metadata"
t.string "service_name", null: false
t.index ["account_id"], name: "index_active_storage_blobs_on_account_id"
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "blob_id", null: false
t.string "variation_digest", null: false
t.index ["account_id"], name: "index_active_storage_variant_records_on_account_id"
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
@@ -96,31 +105,35 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "assignments", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "assignee_id", null: false
t.uuid "assigner_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_assignments_on_account_id"
t.index ["assignee_id", "card_id"], name: "index_assignments_on_assignee_id_and_card_id", unique: true
t.index ["card_id"], name: "index_assignments_on_card_id"
end
create_table "board_publications", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "board_id", null: false
t.datetime "created_at", null: false
t.string "key"
t.datetime "updated_at", null: false
t.index ["account_id", "key"], name: "index_board_publications_on_account_id_and_key"
t.index ["board_id"], name: "index_board_publications_on_board_id"
t.index ["key"], name: "index_board_publications_on_key", unique: true
end
create_table "boards", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.boolean "all_access", default: false, null: false
t.datetime "created_at", null: false
t.uuid "creator_id", null: false
t.string "name", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_boards_on_account_id"
t.index ["creator_id"], name: "index_boards_on_creator_id"
end
@@ -132,39 +145,46 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "card_activity_spikes", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_card_activity_spikes_on_account_id"
t.index ["card_id"], name: "index_card_activity_spikes_on_card_id"
end
create_table "card_engagements", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id"
t.datetime "created_at", null: false
t.string "status", default: "doing", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "status"], name: "index_card_engagements_on_account_id_and_status"
t.index ["card_id"], name: "index_card_engagements_on_card_id"
t.index ["status"], name: "index_card_engagements_on_status"
end
create_table "card_goldnesses", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_card_goldnesses_on_account_id"
t.index ["card_id"], name: "index_card_goldnesses_on_card_id", unique: true
end
create_table "card_not_nows", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "user_id"
t.index ["account_id"], name: "index_card_not_nows_on_account_id"
t.index ["card_id"], name: "index_card_not_nows_on_card_id", unique: true
t.index ["user_id"], name: "index_card_not_nows_on_user_id"
end
create_table "cards", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.uuid "board_id", null: false
t.uuid "column_id"
t.datetime "created_at", null: false
@@ -175,10 +195,10 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.string "status", default: "drafted", null: false
t.string "title"
t.datetime "updated_at", null: false
t.index ["account_id", "last_active_at", "status"], name: "index_cards_on_account_id_and_last_active_at_and_status"
t.index ["account_id", "number"], name: "index_cards_on_account_id_and_number", unique: true
t.index ["board_id"], name: "index_cards_on_board_id"
t.index ["column_id"], name: "index_cards_on_column_id"
t.index ["last_active_at", "status"], name: "index_cards_on_last_active_at_and_status"
end
create_table "closers_filters", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
@@ -189,33 +209,37 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "closures", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "user_id"
t.index ["account_id"], name: "index_closures_on_account_id"
t.index ["card_id", "created_at"], name: "index_closures_on_card_id_and_created_at"
t.index ["card_id"], name: "index_closures_on_card_id", unique: true
t.index ["user_id"], name: "index_closures_on_user_id"
end
create_table "columns", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.uuid "board_id", null: false
t.string "color", null: false
t.datetime "created_at", null: false
t.string "name", null: false
t.integer "position", default: 0, null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_columns_on_account_id"
t.index ["board_id", "position"], name: "index_columns_on_board_id_and_position"
t.index ["board_id"], name: "index_columns_on_board_id"
end
create_table "comments", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.uuid "creator_id", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_comments_on_account_id"
t.index ["card_id"], name: "index_comments_on_card_id"
end
@@ -227,17 +251,19 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "entropies", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.bigint "auto_postpone_period", default: 2592000, null: false
t.uuid "container_id", null: false
t.string "container_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_entropies_on_account_id"
t.index ["container_type", "container_id", "auto_postpone_period"], name: "idx_on_container_type_container_id_auto_postpone_pe_3d79b50517"
t.index ["container_type", "container_id"], name: "index_entropy_configurations_on_container", unique: true
end
create_table "events", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.string "action", null: false
t.uuid "board_id", null: false
t.datetime "created_at", null: false
@@ -246,7 +272,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.string "eventable_type", null: false
t.json "particulars", default: -> { "(json_object())" }
t.datetime "updated_at", null: false
t.index ["action"], name: "index_events_on_summary_id_and_action"
t.index ["account_id", "action"], name: "index_events_on_account_id_and_action"
t.index ["board_id", "action", "created_at"], name: "index_events_on_board_id_and_action_and_created_at"
t.index ["board_id"], name: "index_events_on_board_id"
t.index ["creator_id"], name: "index_events_on_creator_id"
@@ -254,12 +280,13 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "filters", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.uuid "creator_id", null: false
t.json "fields", default: -> { "(json_object())" }, null: false
t.string "params_digest", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_filters_on_account_id"
t.index ["creator_id", "params_digest"], name: "index_filters_on_creator_id_and_params_digest", unique: true
end
@@ -289,32 +316,35 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "mentions", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.uuid "mentionee_id", null: false
t.uuid "mentioner_id", null: false
t.uuid "source_id", null: false
t.string "source_type", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_mentions_on_account_id"
t.index ["mentionee_id"], name: "index_mentions_on_mentionee_id"
t.index ["mentioner_id"], name: "index_mentions_on_mentioner_id"
t.index ["source_type", "source_id"], name: "index_mentions_on_source"
end
create_table "notification_bundles", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.datetime "ends_at", null: false
t.datetime "starts_at", null: false
t.integer "status", default: 0, null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["account_id"], name: "index_notification_bundles_on_account_id"
t.index ["ends_at", "status"], name: "index_notification_bundles_on_ends_at_and_status"
t.index ["user_id", "starts_at", "ends_at"], name: "idx_on_user_id_starts_at_ends_at_7eae5d3ac5"
t.index ["user_id", "status"], name: "index_notification_bundles_on_user_id_and_status"
end
create_table "notifications", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.uuid "creator_id"
t.datetime "read_at"
@@ -322,6 +352,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.string "source_type", null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["account_id"], name: "index_notifications_on_account_id"
t.index ["creator_id"], name: "index_notifications_on_creator_id"
t.index ["source_type", "source_id"], name: "index_notifications_on_source"
t.index ["user_id", "read_at", "created_at"], name: "index_notifications_on_user_id_and_read_at_and_created_at", order: { read_at: :desc, created_at: :desc }
@@ -329,17 +360,19 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "pins", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["account_id"], name: "index_pins_on_account_id"
t.index ["card_id", "user_id"], name: "index_pins_on_card_id_and_user_id", unique: true
t.index ["card_id"], name: "index_pins_on_card_id"
t.index ["user_id"], name: "index_pins_on_user_id"
end
create_table "push_subscriptions", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.string "auth_key"
t.datetime "created_at", null: false
t.string "endpoint"
@@ -347,19 +380,18 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.datetime "updated_at", null: false
t.string "user_agent"
t.uuid "user_id", null: false
t.index ["endpoint", "p256dh_key", "auth_key"], name: "idx_on_endpoint_p256dh_key_auth_key_7553014576"
t.index ["endpoint"], name: "index_push_subscriptions_on_endpoint"
t.index ["user_agent"], name: "index_push_subscriptions_on_user_agent"
t.index ["account_id"], name: "index_push_subscriptions_on_account_id"
t.index ["user_id", "endpoint"], name: "index_push_subscriptions_on_user_id_and_endpoint", unique: true
t.index ["user_id"], name: "index_push_subscriptions_on_user_id"
end
create_table "reactions", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "comment_id", null: false
t.string "content", limit: 16, null: false
t.datetime "created_at", null: false
t.uuid "reacter_id", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_reactions_on_account_id"
t.index ["comment_id"], name: "index_reactions_on_comment_id"
t.index ["reacter_id"], name: "index_reactions_on_reacter_id"
end
@@ -557,10 +589,12 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "search_queries", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.string "terms", limit: 2000, null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["account_id"], name: "index_search_queries_on_account_id"
t.index ["user_id", "terms"], name: "index_search_queries_on_user_id_and_terms", length: { terms: 255 }
t.index ["user_id", "updated_at"], name: "index_search_queries_on_user_id_and_updated_at", unique: true
t.index ["user_id"], name: "index_search_queries_on_user_id"
@@ -581,76 +615,86 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
end
create_table "steps", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.boolean "completed", default: false, null: false
t.text "content", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_steps_on_account_id"
t.index ["card_id", "completed"], name: "index_steps_on_card_id_and_completed"
t.index ["card_id"], name: "index_steps_on_card_id"
end
create_table "taggings", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.uuid "tag_id", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_taggings_on_account_id"
t.index ["card_id", "tag_id"], name: "index_taggings_on_card_id_and_tag_id", unique: true
t.index ["tag_id"], name: "index_taggings_on_tag_id"
end
create_table "tags", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.string "title"
t.datetime "updated_at", null: false
t.index ["title"], name: "index_tags_on_title", unique: true
t.index ["account_id", "title"], name: "index_tags_on_account_id_and_title", unique: true
end
create_table "user_settings", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.integer "bundle_email_frequency", default: 0, null: false
t.datetime "created_at", null: false
t.string "timezone_name"
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.index ["account_id"], name: "index_user_settings_on_account_id"
t.index ["user_id", "bundle_email_frequency"], name: "index_user_settings_on_user_id_and_bundle_email_frequency"
t.index ["user_id"], name: "index_user_settings_on_user_id"
end
create_table "users", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.boolean "active", default: true, null: false
t.datetime "created_at", null: false
t.uuid "identity_id"
t.string "name", null: false
t.string "role", default: "member", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "role"], name: "index_users_on_account_id_and_role"
t.index ["identity_id"], name: "index_users_on_identity_id"
t.index ["role"], name: "index_users_on_role"
end
create_table "watches", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "user_id", null: false
t.boolean "watching", default: true, null: false
t.index ["account_id"], name: "index_watches_on_account_id"
t.index ["card_id"], name: "index_watches_on_card_id"
t.index ["user_id", "card_id"], name: "index_watches_on_user_id_and_card_id"
t.index ["user_id"], name: "index_watches_on_user_id"
end
create_table "webhook_delinquency_trackers", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.integer "consecutive_failures_count", default: 0
t.datetime "created_at", null: false
t.datetime "first_failure_at"
t.datetime "updated_at", null: false
t.uuid "webhook_id", null: false
t.index ["account_id"], name: "index_webhook_delinquency_trackers_on_account_id"
t.index ["webhook_id"], name: "index_webhook_delinquency_trackers_on_webhook_id"
end
create_table "webhook_deliveries", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id", null: false
t.datetime "created_at", null: false
t.uuid "event_id", null: false
t.text "request"
@@ -658,12 +702,13 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.string "state", null: false
t.datetime "updated_at", null: false
t.uuid "webhook_id", null: false
t.index ["account_id"], name: "index_webhook_deliveries_on_account_id"
t.index ["event_id"], name: "index_webhook_deliveries_on_event_id"
t.index ["webhook_id"], name: "index_webhook_deliveries_on_webhook_id"
end
create_table "webhooks", id: :uuid, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.uuid "account_id"
t.uuid "account_id", null: false
t.boolean "active", default: true, null: false
t.uuid "board_id", null: false
t.datetime "created_at", null: false
@@ -672,8 +717,8 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_13_111501) do
t.text "subscribed_actions"
t.datetime "updated_at", null: false
t.text "url", null: false
t.index ["board_id"], name: "index_webhooks_on_board_id"
t.index ["subscribed_actions"], name: "index_webhooks_on_subscribed_actions", length: 255
t.index ["account_id"], name: "index_webhooks_on_account_id"
t.index ["board_id", "subscribed_actions"], name: "index_webhooks_on_board_id_and_subscribed_actions", length: { subscribed_actions: 255 }
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
+10
View File
@@ -270,6 +270,7 @@ class Import
if old_activity_spike
activity_spikes_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
created_at: old_activity_spike.created_at,
updated_at: old_activity_spike.updated_at
@@ -280,6 +281,7 @@ class Import
if old_engagement
engagements_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
status: old_engagement.status,
created_at: old_engagement.created_at,
@@ -291,6 +293,7 @@ class Import
if old_goldness
goldnesses_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
created_at: old_goldness.created_at,
updated_at: old_goldness.updated_at
@@ -301,6 +304,7 @@ class Import
if old_not_now
not_nows_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
user_id: old_not_now.user_id ? mapping[:users][old_not_now.user_id] : nil,
created_at: old_not_now.created_at,
@@ -311,6 +315,7 @@ class Import
old_card.assignments.each do |old_assignment|
assignments_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
assignee_id: mapping[:users][old_assignment.assignee_id],
assigner_id: mapping[:users][old_assignment.assigner_id],
@@ -323,6 +328,7 @@ class Import
if old_closure
closures_to_insert << {
id: generate_uuid,
account_id: account.id,
card_id: new_id,
user_id: old_closure.user_id ? mapping[:users][old_closure.user_id] : nil,
created_at: old_closure.created_at,
@@ -442,6 +448,7 @@ class Import
accesses_to_insert << {
id: new_id,
account_id: account.id,
board_id: mapping[:boards][old_access.board_id],
user_id: mapping[:users][old_access.user_id],
involvement: old_access.involvement,
@@ -701,6 +708,7 @@ class Import
ActiveStorage::VariantRecord.find_or_create_by!(
id: new_variant_blob.id,
account_id: account.id,
blob_id: new_blob.id,
variation_digest: old_variant_record.variation_digest
)
@@ -772,6 +780,7 @@ class Import
watches_to_insert << {
id: new_id,
account_id: account.id,
user_id: mapping[:users][old_watch.user_id],
card_id: mapping[:cards][old_watch.card_id],
watching: old_watch.watching,
@@ -800,6 +809,7 @@ class Import
pins_to_insert << {
id: new_id,
account_id: account.id,
user_id: mapping[:users][old_pin.user_id],
card_id: mapping[:cards][old_pin.card_id],
created_at: old_pin.created_at,
+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
+1
View File
@@ -1,4 +1,5 @@
shipping:
id: <%= ActiveRecord::FixtureSet.identify("shipping_closure", :uuid) %>
account: 37s_uuid
card: shipping_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
+2
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
+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