mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 13:22:41 +02:00
nit
This commit is contained in:
commit
aa90da602b
26 changed files with 406 additions and 234 deletions
|
|
@ -24,9 +24,7 @@ def enum_exists(enum_name: str) -> bool:
|
|||
"""Check if an enum type exists in the database."""
|
||||
conn = op.get_bind()
|
||||
result = conn.execute(
|
||||
sa.text(
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"
|
||||
),
|
||||
sa.text("SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"),
|
||||
{"enum_name": enum_name},
|
||||
)
|
||||
return result.scalar()
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ def enum_exists(enum_name: str) -> bool:
|
|||
"""Check if an enum type exists in the database."""
|
||||
conn = op.get_bind()
|
||||
result = conn.execute(
|
||||
sa.text(
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"
|
||||
),
|
||||
sa.text("SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"),
|
||||
{"enum_name": enum_name},
|
||||
)
|
||||
return result.scalar()
|
||||
|
|
|
|||
|
|
@ -197,9 +197,7 @@ def enum_exists(enum_name: str) -> bool:
|
|||
"""Check if an enum type exists in the database."""
|
||||
conn = op.get_bind()
|
||||
result = conn.execute(
|
||||
sa.text(
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"
|
||||
),
|
||||
sa.text("SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = :enum_name)"),
|
||||
{"enum_name": enum_name},
|
||||
)
|
||||
return result.scalar()
|
||||
|
|
|
|||
|
|
@ -1,96 +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 sqlalchemy import text
|
||||
|
||||
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."""
|
||||
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
|
||||
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 dropping
|
||||
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'
|
||||
)
|
||||
|
||||
# Only restore old constraint if it doesn't exist
|
||||
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']
|
||||
)
|
||||
|
|
@ -5,6 +5,7 @@ Revises: 63
|
|||
Create Date: 2026-01-09 15:19:51.827647
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from alembic import op
|
||||
|
|
@ -4,8 +4,8 @@ This migration adds:
|
|||
- display_name column for user's full name from OAuth
|
||||
- avatar_url column for user's profile picture URL from OAuth
|
||||
|
||||
Revision ID: 62
|
||||
Revises: 61
|
||||
Revision ID: 64
|
||||
Revises: 63
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
|
@ -13,8 +13,8 @@ from collections.abc import Sequence
|
|||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "62"
|
||||
down_revision: str | None = "61"
|
||||
revision: str = "64"
|
||||
down_revision: str | None = "63"
|
||||
branch_labels: 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
|
||||
|
||||
Revision ID: 63
|
||||
Revises: 62
|
||||
Revision ID: 65
|
||||
Revises: 64
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "63"
|
||||
down_revision: str | None = "62"
|
||||
revision: str = "65"
|
||||
down_revision: str | None = "64"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
|
@ -37,6 +37,10 @@ def upgrade() -> None:
|
|||
|
||||
def downgrade() -> None:
|
||||
"""Remove author_id column from new_chat_messages table."""
|
||||
op.execute("DROP INDEX IF EXISTS ix_new_chat_messages_author_id")
|
||||
op.execute("ALTER TABLE new_chat_messages DROP COLUMN IF EXISTS author_id")
|
||||
|
||||
op.execute(
|
||||
"""
|
||||
DROP INDEX IF EXISTS ix_new_chat_messages_author_id;
|
||||
ALTER TABLE new_chat_messages
|
||||
DROP COLUMN IF EXISTS author_id;
|
||||
"""
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue