gate2: fix all migrations for fresh DB installation
This commit is contained in:
@@ -30,7 +30,7 @@ def upgrade() -> None:
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||
sa.UniqueConstraint("tenant_id", "name", name="uq_workspaces_tenant_name"),
|
||||
)
|
||||
op.create_index("ix_workspaces_tenant", "workspaces", ["tenant_id"])
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_workspaces_tenant ON workspaces (tenant_id)')
|
||||
op.execute(
|
||||
"CREATE UNIQUE INDEX uq_workspace_default_per_tenant "
|
||||
"ON workspaces (tenant_id) WHERE is_default = true"
|
||||
@@ -50,7 +50,7 @@ def upgrade() -> None:
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||
sa.UniqueConstraint("tenant_id", "workspace_id", "module_key", name="uq_wm_tenant_workspace_module"),
|
||||
)
|
||||
op.create_index("ix_wm_workspace", "workspace_modules", ["tenant_id", "workspace_id", "menu_order"])
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_wm_workspace ON workspace_modules (tenant_id, workspace_id, menu_order)')
|
||||
|
||||
# workspace_users
|
||||
op.create_table(
|
||||
@@ -66,8 +66,8 @@ def upgrade() -> None:
|
||||
sa.UniqueConstraint("tenant_id", "workspace_id", "user_id", name="uq_wu_tenant_workspace_user"),
|
||||
sa.CheckConstraint("role IN ('member', 'manager')", name="ck_wu_role"),
|
||||
)
|
||||
op.create_index("ix_wu_workspace", "workspace_users", ["tenant_id", "workspace_id"])
|
||||
op.create_index("ix_wu_user", "workspace_users", ["tenant_id", "user_id"])
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_wu_workspace ON workspace_users (tenant_id, workspace_id)')
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_wu_user ON workspace_users (tenant_id, user_id)')
|
||||
|
||||
# workspace_widgets
|
||||
op.create_table(
|
||||
@@ -84,7 +84,7 @@ def upgrade() -> None:
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||
)
|
||||
op.create_index("ix_ww_workspace", "workspace_widgets", ["tenant_id", "workspace_id"])
|
||||
op.execute('CREATE INDEX IF NOT EXISTS ix_ww_workspace ON workspace_widgets (tenant_id, workspace_id)')
|
||||
|
||||
# RLS on all workspace tables
|
||||
for table in ["workspaces", "workspace_modules", "workspace_users", "workspace_widgets"]:
|
||||
|
||||
Reference in New Issue
Block a user