mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-10 20:35:17 +02:00
make migration idempotent
This commit is contained in:
parent
a627cc709e
commit
68dc7723af
1 changed files with 4 additions and 8 deletions
|
|
@ -43,7 +43,7 @@ def upgrade() -> None:
|
|||
# Add unique partial index on public_share_token (only non-null values)
|
||||
op.execute(
|
||||
"""
|
||||
CREATE UNIQUE INDEX ix_new_chat_threads_public_share_token
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS ix_new_chat_threads_public_share_token
|
||||
ON new_chat_threads(public_share_token)
|
||||
WHERE public_share_token IS NOT NULL
|
||||
"""
|
||||
|
|
@ -52,7 +52,7 @@ def upgrade() -> None:
|
|||
# Add partial index on public_share_enabled for fast public chat queries
|
||||
op.execute(
|
||||
"""
|
||||
CREATE INDEX ix_new_chat_threads_public_share_enabled
|
||||
CREATE INDEX IF NOT EXISTS ix_new_chat_threads_public_share_enabled
|
||||
ON new_chat_threads(public_share_enabled)
|
||||
WHERE public_share_enabled = TRUE
|
||||
"""
|
||||
|
|
@ -61,11 +61,7 @@ def upgrade() -> None:
|
|||
|
||||
def downgrade() -> None:
|
||||
"""Remove public sharing columns from new_chat_threads."""
|
||||
op.drop_index(
|
||||
"ix_new_chat_threads_public_share_enabled", table_name="new_chat_threads"
|
||||
)
|
||||
op.drop_index(
|
||||
"ix_new_chat_threads_public_share_token", table_name="new_chat_threads"
|
||||
)
|
||||
op.execute("DROP INDEX IF EXISTS ix_new_chat_threads_public_share_enabled")
|
||||
op.execute("DROP INDEX IF EXISTS ix_new_chat_threads_public_share_token")
|
||||
op.drop_column("new_chat_threads", "public_share_enabled")
|
||||
op.drop_column("new_chat_threads", "public_share_token")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue