Fix: register plugin routes in create_app() not lifespan(); add status column to contacts migration 0039; add updated_at to user_tenants migration 0037
This commit is contained in:
@@ -80,6 +80,11 @@ def upgrade() -> None:
|
||||
if status_col_result is None:
|
||||
op.add_column("user_tenants", sa.Column("status", sa.String(20), nullable=False, server_default="active"))
|
||||
|
||||
# ── 4b. Add updated_at column to user_tenants ──────────────────────────
|
||||
updated_col_result = conn.execute(sa.text(_column_exists("user_tenants", "updated_at"))).fetchone()
|
||||
if updated_col_result is None:
|
||||
op.add_column("user_tenants", sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True, server_default=sa.func.now()))
|
||||
|
||||
# ── 5. Data migration: copy tenant_id, role, role_id from users to user_tenants ─
|
||||
# Only create UserTenant rows that don't already exist
|
||||
conn.execute(sa.text("""
|
||||
|
||||
@@ -54,6 +54,11 @@ def _constraint_exists(table: str, constraint: str) -> str:
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
|
||||
# ── 0. Add status column to contacts (for state machine) ──
|
||||
status_col = conn.execute(sa.text(_column_exists("contacts", "status"))).fetchone()
|
||||
if not status_col:
|
||||
op.add_column("contacts", sa.Column("status", sa.String(20), nullable=False, server_default="lead"))
|
||||
|
||||
# ── 1a. Rename surfix → suffix ──
|
||||
result = conn.execute(sa.text(_column_exists("contacts", "surfix"))).fetchone()
|
||||
if result:
|
||||
|
||||
Reference in New Issue
Block a user