mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 21:32:39 +02:00
chore: linting
This commit is contained in:
parent
3375aeb9bc
commit
7ae68455b3
20 changed files with 128 additions and 103 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()
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ Revises: 61
|
|||
Create Date: 2026-01-09 15:19:51.827647
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '62'
|
||||
down_revision: str | None = '61'
|
||||
revision: str = "62"
|
||||
down_revision: str | None = "61"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Revises: 62
|
|||
Create Date: 2026-01-13 12:23:31.481643
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from sqlalchemy import text
|
||||
|
|
@ -12,8 +13,8 @@ from sqlalchemy import text
|
|||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '63'
|
||||
down_revision: str | None = '62'
|
||||
revision: str = "63"
|
||||
down_revision: str | None = "62"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ 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("""
|
||||
|
|
@ -31,14 +32,14 @@ def upgrade() -> None:
|
|||
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'
|
||||
"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("""
|
||||
|
|
@ -48,19 +49,19 @@ def upgrade() -> None:
|
|||
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']
|
||||
"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("""
|
||||
|
|
@ -70,14 +71,14 @@ def downgrade() -> None:
|
|||
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'
|
||||
"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("""
|
||||
|
|
@ -87,10 +88,10 @@ def downgrade() -> None:
|
|||
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']
|
||||
"uq_searchspace_user_connector_type",
|
||||
"search_source_connectors",
|
||||
["search_space_id", "user_id", "connector_type"],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -44,4 +44,3 @@ def downgrade() -> None:
|
|||
DROP COLUMN IF EXISTS author_id;
|
||||
"""
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue