mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
736 B
17 lines
736 B
# frozen_string_literal: true
|
|
|
|
# Migration 1: Add institution_id to account_access
|
|
# Part of Winston's 4-layer data isolation foundation
|
|
class AddInstitutionIdToAccountAccess < ActiveRecord::Migration[7.0]
|
|
def change
|
|
# Step 1: Add nullable institution_id column
|
|
add_reference :account_accesses, :institution, foreign_key: { to_table: :institutions }, index: true, null: true
|
|
|
|
# Step 2: Add foreign key constraint
|
|
# Note: We'll add the constraint after backfilling data in a separate migration
|
|
# to avoid locking issues on large tables
|
|
|
|
# Step 3: Add unique index for [user_id, institution_id] to prevent duplicate roles
|
|
# This will be added after data backfill when institution_id is non-nullable
|
|
end
|
|
end |