gate2: fix all migrations for fresh DB installation
This commit is contained in:
@@ -34,17 +34,8 @@ def upgrade() -> None:
|
||||
) STORED
|
||||
"""
|
||||
)
|
||||
op.create_index(
|
||||
"ix_companies_search_vec",
|
||||
"companies",
|
||||
["search_tsv"],
|
||||
postgresql_using="gin",
|
||||
)
|
||||
op.create_index(
|
||||
"ix_companies_industry",
|
||||
"companies",
|
||||
["tenant_id", "industry"],
|
||||
)
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_companies_search_vec ON companies (search_tsv)')
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_companies_industry ON companies (tenant_id, industry)')
|
||||
|
||||
# --- contacts ---
|
||||
op.create_table(
|
||||
@@ -84,9 +75,9 @@ def upgrade() -> None:
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
|
||||
sa.UniqueConstraint("company_id", "contact_id", "tenant_id", name="uq_company_contact_tenant"),
|
||||
)
|
||||
op.create_index("ix_cc_company", "company_contacts", ["company_id"])
|
||||
op.create_index("ix_cc_contact", "company_contacts", ["contact_id"])
|
||||
op.create_index("ix_company_contacts_tenant_id", "company_contacts", ["tenant_id"])
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_cc_company ON company_contacts (company_id)')
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_cc_contact ON company_contacts (contact_id)')
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_company_contacts_tenant_id ON company_contacts (tenant_id)')
|
||||
|
||||
# --- RLS on new tenant-scoped tables ---
|
||||
for table in ["contacts", "company_contacts"]:
|
||||
|
||||
Reference in New Issue
Block a user