mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-11 13:32:16 +02:00
Fix Tag Integer Enums (#1388)
This commit is contained in:
parent
d756ad34f3
commit
ead7a80297
@ -0,0 +1,39 @@
|
||||
"""Delete Tags with wrong Enum
|
||||
|
||||
Revision ID: fad14119fb92
|
||||
Revises: 72bdc9929a46
|
||||
Create Date: 2024-04-25 17:05:09.695703
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "fad14119fb92"
|
||||
down_revision = "72bdc9929a46"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Some documents may lose their tags but this is the only way as the enum
|
||||
# mapping may have changed since tag switched to string (it will be reindexed anyway)
|
||||
op.execute(
|
||||
"""
|
||||
DELETE FROM document__tag
|
||||
WHERE tag_id IN (
|
||||
SELECT id FROM tag
|
||||
WHERE source ~ '^[0-9]+$'
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
op.execute(
|
||||
"""
|
||||
DELETE FROM tag
|
||||
WHERE source ~ '^[0-9]+$'
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
@ -1063,7 +1063,9 @@ class PermissionSyncRun(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
# Not strictly needed but makes it easy to use without fetching from cc_pair
|
||||
source_type: Mapped[DocumentSource] = mapped_column(Enum(DocumentSource))
|
||||
source_type: Mapped[DocumentSource] = mapped_column(
|
||||
Enum(DocumentSource, native_enum=False)
|
||||
)
|
||||
# Currently all sync jobs are handled as a group permission sync or a user permission sync
|
||||
update_type: Mapped[PermissionSyncJobType] = mapped_column(
|
||||
Enum(PermissionSyncJobType)
|
||||
@ -1093,7 +1095,9 @@ class ExternalPermission(Base):
|
||||
# Email is needed because we want to keep track of users not in Danswer to simplify process
|
||||
# when the user joins
|
||||
user_email: Mapped[str] = mapped_column(String)
|
||||
source_type: Mapped[DocumentSource] = mapped_column(Enum(DocumentSource))
|
||||
source_type: Mapped[DocumentSource] = mapped_column(
|
||||
Enum(DocumentSource, native_enum=False)
|
||||
)
|
||||
external_permission_group: Mapped[str] = mapped_column(String)
|
||||
user = relationship("User")
|
||||
|
||||
@ -1120,6 +1124,8 @@ class EmailToExternalUserCache(Base):
|
||||
# Email is needed because we want to keep track of users not in Danswer to simplify process
|
||||
# when the user joins
|
||||
user_email: Mapped[str] = mapped_column(String)
|
||||
source_type: Mapped[DocumentSource] = mapped_column(Enum(DocumentSource))
|
||||
source_type: Mapped[DocumentSource] = mapped_column(
|
||||
Enum(DocumentSource, native_enum=False)
|
||||
)
|
||||
|
||||
user = relationship("User")
|
||||
|
Loading…
x
Reference in New Issue
Block a user