mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-06 20:15:17 +02:00
feat: add LOCAL_FOLDER_FILE document type and update document_versions table management
This commit is contained in:
parent
8e58094a86
commit
40ade4889e
1 changed files with 12 additions and 21 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
"""Add local folder connector enums and document_versions table
|
"""Add LOCAL_FOLDER_FILE document type and document_versions table
|
||||||
|
|
||||||
Revision ID: 117
|
Revision ID: 117
|
||||||
Revises: 116
|
Revises: 116
|
||||||
|
|
@ -21,23 +21,6 @@ PUBLICATION_NAME = "zero_publication"
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
conn = op.get_bind()
|
conn = op.get_bind()
|
||||||
|
|
||||||
# Add LOCAL_FOLDER_CONNECTOR to searchsourceconnectortype enum
|
|
||||||
op.execute(
|
|
||||||
"""
|
|
||||||
DO $$
|
|
||||||
BEGIN
|
|
||||||
IF NOT EXISTS (
|
|
||||||
SELECT 1 FROM pg_type t
|
|
||||||
JOIN pg_enum e ON t.oid = e.enumtypid
|
|
||||||
WHERE t.typname = 'searchsourceconnectortype' AND e.enumlabel = 'LOCAL_FOLDER_CONNECTOR'
|
|
||||||
) THEN
|
|
||||||
ALTER TYPE searchsourceconnectortype ADD VALUE 'LOCAL_FOLDER_CONNECTOR';
|
|
||||||
END IF;
|
|
||||||
END
|
|
||||||
$$;
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add LOCAL_FOLDER_FILE to documenttype enum
|
# Add LOCAL_FOLDER_FILE to documenttype enum
|
||||||
op.execute(
|
op.execute(
|
||||||
"""
|
"""
|
||||||
|
|
@ -126,8 +109,16 @@ def downgrade() -> None:
|
||||||
{"name": PUBLICATION_NAME},
|
{"name": PUBLICATION_NAME},
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if pub_exists:
|
if pub_exists:
|
||||||
|
already_in_pub = conn.execute(
|
||||||
|
sa.text(
|
||||||
|
"SELECT 1 FROM pg_publication_tables "
|
||||||
|
"WHERE pubname = :name AND tablename = 'document_versions'"
|
||||||
|
),
|
||||||
|
{"name": PUBLICATION_NAME},
|
||||||
|
).fetchone()
|
||||||
|
if already_in_pub:
|
||||||
op.execute(
|
op.execute(
|
||||||
f"ALTER PUBLICATION {PUBLICATION_NAME} DROP TABLE IF EXISTS document_versions"
|
f"ALTER PUBLICATION {PUBLICATION_NAME} DROP TABLE document_versions"
|
||||||
)
|
)
|
||||||
|
|
||||||
op.execute("DROP INDEX IF EXISTS ix_document_versions_created_at")
|
op.execute("DROP INDEX IF EXISTS ix_document_versions_created_at")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue