mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
fix: migrations
This commit is contained in:
parent
92e7b3aef3
commit
bff37789c8
5 changed files with 106 additions and 60 deletions
|
|
@ -1,50 +0,0 @@
|
||||||
"""allow_multiple_connectors_with_unique_names
|
|
||||||
|
|
||||||
Revision ID: 5263aa4e7f94
|
|
||||||
Revises: a1b2c3d4e5f6
|
|
||||||
Create Date: 2026-01-13 12:23:31.481643
|
|
||||||
|
|
||||||
"""
|
|
||||||
from collections.abc import Sequence
|
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision: str = '5263aa4e7f94'
|
|
||||||
down_revision: str | None = 'a1b2c3d4e5f6'
|
|
||||||
branch_labels: str | Sequence[str] | None = None
|
|
||||||
depends_on: str | Sequence[str] | None = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
"""Upgrade schema."""
|
|
||||||
# Drop the old unique constraint
|
|
||||||
op.drop_constraint(
|
|
||||||
'uq_searchspace_user_connector_type',
|
|
||||||
'search_source_connectors',
|
|
||||||
type_='unique'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create new unique constraint that includes name
|
|
||||||
op.create_unique_constraint(
|
|
||||||
'uq_searchspace_user_connector_type_name',
|
|
||||||
'search_source_connectors',
|
|
||||||
['search_space_id', 'user_id', 'connector_type', 'name']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
"""Downgrade schema."""
|
|
||||||
# Drop the new constraint
|
|
||||||
op.drop_constraint(
|
|
||||||
'uq_searchspace_user_connector_type_name',
|
|
||||||
'search_source_connectors',
|
|
||||||
type_='unique'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Restore the old constraint
|
|
||||||
op.create_unique_constraint(
|
|
||||||
'uq_searchspace_user_connector_type',
|
|
||||||
'search_source_connectors',
|
|
||||||
['search_space_id', 'user_id', 'connector_type']
|
|
||||||
)
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"""Add MCP connector type
|
"""Add MCP connector type
|
||||||
|
|
||||||
Revision ID: a1b2c3d4e5f6
|
Revision ID: 62
|
||||||
Revises: 61
|
Revises: 61
|
||||||
Create Date: 2026-01-09 15:19:51.827647
|
Create Date: 2026-01-09 15:19:51.827647
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ from collections.abc import Sequence
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = 'a1b2c3d4e5f6'
|
revision: str = '62'
|
||||||
down_revision: str | None = '61'
|
down_revision: str | None = '61'
|
||||||
branch_labels: str | Sequence[str] | None = None
|
branch_labels: str | Sequence[str] | None = None
|
||||||
depends_on: str | Sequence[str] | None = None
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
"""allow_multiple_connectors_with_unique_names
|
||||||
|
|
||||||
|
Revision ID: 63
|
||||||
|
Revises: 62
|
||||||
|
Create Date: 2026-01-13 12:23:31.481643
|
||||||
|
|
||||||
|
"""
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '63'
|
||||||
|
down_revision: str | None = '62'
|
||||||
|
branch_labels: str | Sequence[str] | None = None
|
||||||
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
connection = op.get_bind()
|
||||||
|
|
||||||
|
# Check if old constraint exists before trying to drop it
|
||||||
|
old_constraint_exists = connection.execute(
|
||||||
|
text("""
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_name='search_source_connectors'
|
||||||
|
AND constraint_type='UNIQUE'
|
||||||
|
AND constraint_name='uq_searchspace_user_connector_type'
|
||||||
|
""")
|
||||||
|
).scalar()
|
||||||
|
|
||||||
|
if old_constraint_exists:
|
||||||
|
op.drop_constraint(
|
||||||
|
'uq_searchspace_user_connector_type',
|
||||||
|
'search_source_connectors',
|
||||||
|
type_='unique'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check if new constraint already exists before creating it
|
||||||
|
new_constraint_exists = connection.execute(
|
||||||
|
text("""
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_name='search_source_connectors'
|
||||||
|
AND constraint_type='UNIQUE'
|
||||||
|
AND constraint_name='uq_searchspace_user_connector_type_name'
|
||||||
|
""")
|
||||||
|
).scalar()
|
||||||
|
|
||||||
|
if not new_constraint_exists:
|
||||||
|
op.create_unique_constraint(
|
||||||
|
'uq_searchspace_user_connector_type_name',
|
||||||
|
'search_source_connectors',
|
||||||
|
['search_space_id', 'user_id', 'connector_type', 'name']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
connection = op.get_bind()
|
||||||
|
|
||||||
|
# Check if new constraint exists before trying to drop it
|
||||||
|
new_constraint_exists = connection.execute(
|
||||||
|
text("""
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_name='search_source_connectors'
|
||||||
|
AND constraint_type='UNIQUE'
|
||||||
|
AND constraint_name='uq_searchspace_user_connector_type_name'
|
||||||
|
""")
|
||||||
|
).scalar()
|
||||||
|
|
||||||
|
if new_constraint_exists:
|
||||||
|
op.drop_constraint(
|
||||||
|
'uq_searchspace_user_connector_type_name',
|
||||||
|
'search_source_connectors',
|
||||||
|
type_='unique'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check if old constraint already exists before creating it
|
||||||
|
old_constraint_exists = connection.execute(
|
||||||
|
text("""
|
||||||
|
SELECT 1 FROM information_schema.table_constraints
|
||||||
|
WHERE table_name='search_source_connectors'
|
||||||
|
AND constraint_type='UNIQUE'
|
||||||
|
AND constraint_name='uq_searchspace_user_connector_type'
|
||||||
|
""")
|
||||||
|
).scalar()
|
||||||
|
|
||||||
|
if not old_constraint_exists:
|
||||||
|
op.create_unique_constraint(
|
||||||
|
'uq_searchspace_user_connector_type',
|
||||||
|
'search_source_connectors',
|
||||||
|
['search_space_id', 'user_id', 'connector_type']
|
||||||
|
)
|
||||||
|
|
@ -4,8 +4,8 @@ This migration adds:
|
||||||
- display_name column for user's full name from OAuth
|
- display_name column for user's full name from OAuth
|
||||||
- avatar_url column for user's profile picture URL from OAuth
|
- avatar_url column for user's profile picture URL from OAuth
|
||||||
|
|
||||||
Revision ID: 62
|
Revision ID: 64
|
||||||
Revises: 61
|
Revises: 63
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
|
@ -13,8 +13,8 @@ from collections.abc import Sequence
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = "62"
|
revision: str = "64"
|
||||||
down_revision: str | None = "61"
|
down_revision: str | None = "63"
|
||||||
branch_labels: str | Sequence[str] | None = None
|
branch_labels: str | Sequence[str] | None = None
|
||||||
depends_on: str | Sequence[str] | None = None
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
"""Add author_id column to new_chat_messages table
|
"""Add author_id column to new_chat_messages table
|
||||||
|
|
||||||
Revision ID: 63
|
Revision ID: 65
|
||||||
Revises: 62
|
Revises: 64
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
revision: str = "63"
|
revision: str = "65"
|
||||||
down_revision: str | None = "62"
|
down_revision: str | None = "64"
|
||||||
branch_labels: str | Sequence[str] | None = None
|
branch_labels: str | Sequence[str] | None = None
|
||||||
depends_on: str | Sequence[str] | None = None
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue