-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from uhh-lt/remove-adocs-from-endpoints
Remove adocs from endpoints
- Loading branch information
Showing
112 changed files
with
1,939 additions
and
2,505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
backend/src/alembic/versions/714fa3c0323d_remove_adoc_from_object_handle.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
"""Remove adoc from object handle | ||
Revision ID: 714fa3c0323d | ||
Revises: 53ec37ba68dd | ||
Create Date: 2024-09-26 12:47:52.297367 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "714fa3c0323d" | ||
down_revision: Union[str, None] = "53ec37ba68dd" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index("ix_objecthandle_annotation_document_id", table_name="objecthandle") | ||
op.drop_constraint( | ||
"UC_only_one_object_handle_per_instance", "objecthandle", type_="unique" | ||
) | ||
op.create_unique_constraint( | ||
"UC_only_one_object_handle_per_instance", | ||
"objecthandle", | ||
[ | ||
"user_id", | ||
"project_id", | ||
"code_id", | ||
"current_code_id", | ||
"source_document_id", | ||
"span_annotation_id", | ||
"span_group_id", | ||
"document_tag_id", | ||
"action_id", | ||
"memo_id", | ||
], | ||
) | ||
op.drop_index("idx_for_uc_work_with_null", table_name="objecthandle") | ||
op.create_index( | ||
"idx_for_uc_work_with_null", | ||
"objecthandle", | ||
[ | ||
sa.text("coalesce(user_id, 0)"), | ||
sa.text("coalesce(project_id, 0)"), | ||
sa.text("coalesce(code_id, 0)"), | ||
sa.text("coalesce(current_code_id, 0)"), | ||
sa.text("coalesce(source_document_id, 0)"), | ||
sa.text("coalesce(span_annotation_id, 0)"), | ||
sa.text("coalesce(bbox_annotation_id, 0)"), | ||
sa.text("coalesce(span_group_id, 0)"), | ||
sa.text("coalesce(document_tag_id, 0)"), | ||
sa.text("coalesce(action_id, 0)"), | ||
sa.text("coalesce(memo_id, 0)"), | ||
], | ||
unique=True, | ||
) | ||
op.drop_constraint( | ||
"objecthandle_annotation_document_id_fkey", "objecthandle", type_="foreignkey" | ||
) | ||
op.drop_column("objecthandle", "annotation_document_id") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"objecthandle", | ||
sa.Column( | ||
"annotation_document_id", sa.INTEGER(), autoincrement=False, nullable=True | ||
), | ||
) | ||
op.create_foreign_key( | ||
"objecthandle_annotation_document_id_fkey", | ||
"objecthandle", | ||
"annotationdocument", | ||
["annotation_document_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) | ||
op.drop_index("idx_for_uc_work_with_null", table_name="objecthandle") | ||
op.create_index( | ||
"idx_for_uc_work_with_null", | ||
"objecthandle", | ||
[ | ||
sa.text("COALESCE(user_id, 0)"), | ||
sa.text("COALESCE(project_id, 0)"), | ||
sa.text("COALESCE(code_id, 0)"), | ||
sa.text("COALESCE(current_code_id, 0)"), | ||
sa.text("COALESCE(source_document_id, 0)"), | ||
sa.text("COALESCE(annotation_document_id, 0)"), | ||
sa.text("COALESCE(span_annotation_id, 0)"), | ||
sa.text("COALESCE(bbox_annotation_id, 0)"), | ||
sa.text("COALESCE(span_group_id, 0)"), | ||
sa.text("COALESCE(document_tag_id, 0)"), | ||
sa.text("COALESCE(action_id, 0)"), | ||
sa.text("COALESCE(memo_id, 0)"), | ||
], | ||
unique=False, | ||
) | ||
op.drop_constraint( | ||
"UC_only_one_object_handle_per_instance", "objecthandle", type_="unique" | ||
) | ||
op.create_unique_constraint( | ||
"UC_only_one_object_handle_per_instance", | ||
"objecthandle", | ||
[ | ||
"user_id", | ||
"project_id", | ||
"code_id", | ||
"current_code_id", | ||
"source_document_id", | ||
"annotation_document_id", | ||
"span_annotation_id", | ||
"span_group_id", | ||
"document_tag_id", | ||
"action_id", | ||
"memo_id", | ||
], | ||
) | ||
op.create_index( | ||
"ix_objecthandle_annotation_document_id", | ||
"objecthandle", | ||
["annotation_document_id"], | ||
unique=False, | ||
) | ||
# ### end Alembic commands ### |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.