|
| 1 | +"""vscode launcher |
| 2 | +
|
| 3 | +Revision ID: d7e768a5b23d |
| 4 | +Revises: f3108bb5e496 |
| 5 | +Create Date: 2025-01-22 08:51:22.353360 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from typing import Sequence, Union |
| 10 | + |
| 11 | +import sqlalchemy as sa |
| 12 | + |
| 13 | +from alembic import op |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision: str = "d7e768a5b23d" |
| 17 | +down_revision: Union[str, None] = "f3108bb5e496" |
| 18 | +branch_labels: Union[str, Sequence[str], None] = None |
| 19 | +depends_on: Union[str, Sequence[str], None] = None |
| 20 | + |
| 21 | + |
| 22 | +def upgrade() -> None: |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.create_table( |
| 25 | + "documenttagrecommendation", |
| 26 | + sa.Column("task_id", sa.Integer(), nullable=False), |
| 27 | + sa.Column("model_name", sa.String(), nullable=True), |
| 28 | + sa.Column( |
| 29 | + "created", sa.DateTime(), server_default=sa.text("now()"), nullable=False |
| 30 | + ), |
| 31 | + sa.Column("user_id", sa.Integer(), nullable=False), |
| 32 | + sa.Column("project_id", sa.Integer(), nullable=False), |
| 33 | + sa.ForeignKeyConstraint(["project_id"], ["project.id"], ondelete="CASCADE"), |
| 34 | + sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"), |
| 35 | + sa.PrimaryKeyConstraint("task_id"), |
| 36 | + ) |
| 37 | + op.create_index( |
| 38 | + op.f("ix_documenttagrecommendation_created"), |
| 39 | + "documenttagrecommendation", |
| 40 | + ["created"], |
| 41 | + unique=False, |
| 42 | + ) |
| 43 | + op.create_index( |
| 44 | + op.f("ix_documenttagrecommendation_model_name"), |
| 45 | + "documenttagrecommendation", |
| 46 | + ["model_name"], |
| 47 | + unique=False, |
| 48 | + ) |
| 49 | + op.create_index( |
| 50 | + op.f("ix_documenttagrecommendation_project_id"), |
| 51 | + "documenttagrecommendation", |
| 52 | + ["project_id"], |
| 53 | + unique=False, |
| 54 | + ) |
| 55 | + op.create_index( |
| 56 | + op.f("ix_documenttagrecommendation_task_id"), |
| 57 | + "documenttagrecommendation", |
| 58 | + ["task_id"], |
| 59 | + unique=False, |
| 60 | + ) |
| 61 | + op.create_index( |
| 62 | + op.f("ix_documenttagrecommendation_user_id"), |
| 63 | + "documenttagrecommendation", |
| 64 | + ["user_id"], |
| 65 | + unique=False, |
| 66 | + ) |
| 67 | + op.create_table( |
| 68 | + "documenttagrecommendationlink", |
| 69 | + sa.Column("id", sa.Integer(), nullable=False), |
| 70 | + sa.Column("recommendation_task_id", sa.Integer(), nullable=False), |
| 71 | + sa.Column("source_document_id", sa.Integer(), nullable=False), |
| 72 | + sa.Column("predicted_tag_id", sa.Integer(), nullable=False), |
| 73 | + sa.Column("prediction_score", sa.Float(), nullable=True), |
| 74 | + sa.Column("is_accepted", sa.Boolean(), nullable=True), |
| 75 | + sa.ForeignKeyConstraint( |
| 76 | + ["predicted_tag_id"], ["documenttag.id"], ondelete="CASCADE" |
| 77 | + ), |
| 78 | + sa.ForeignKeyConstraint( |
| 79 | + ["recommendation_task_id"], |
| 80 | + ["documenttagrecommendation.task_id"], |
| 81 | + ondelete="CASCADE", |
| 82 | + ), |
| 83 | + sa.ForeignKeyConstraint( |
| 84 | + ["source_document_id"], ["sourcedocument.id"], ondelete="CASCADE" |
| 85 | + ), |
| 86 | + sa.PrimaryKeyConstraint("id"), |
| 87 | + ) |
| 88 | + op.create_index( |
| 89 | + op.f("ix_documenttagrecommendationlink_id"), |
| 90 | + "documenttagrecommendationlink", |
| 91 | + ["id"], |
| 92 | + unique=False, |
| 93 | + ) |
| 94 | + op.create_index( |
| 95 | + op.f("ix_documenttagrecommendationlink_is_accepted"), |
| 96 | + "documenttagrecommendationlink", |
| 97 | + ["is_accepted"], |
| 98 | + unique=False, |
| 99 | + ) |
| 100 | + op.create_index( |
| 101 | + op.f("ix_documenttagrecommendationlink_prediction_score"), |
| 102 | + "documenttagrecommendationlink", |
| 103 | + ["prediction_score"], |
| 104 | + unique=False, |
| 105 | + ) |
| 106 | + # ### end Alembic commands ### |
| 107 | + |
| 108 | + |
| 109 | +def downgrade() -> None: |
| 110 | + # ### commands auto generated by Alembic - please adjust! ### |
| 111 | + op.drop_index( |
| 112 | + op.f("ix_documenttagrecommendationlink_prediction_score"), |
| 113 | + table_name="documenttagrecommendationlink", |
| 114 | + ) |
| 115 | + op.drop_index( |
| 116 | + op.f("ix_documenttagrecommendationlink_is_accepted"), |
| 117 | + table_name="documenttagrecommendationlink", |
| 118 | + ) |
| 119 | + op.drop_index( |
| 120 | + op.f("ix_documenttagrecommendationlink_id"), |
| 121 | + table_name="documenttagrecommendationlink", |
| 122 | + ) |
| 123 | + op.drop_table("documenttagrecommendationlink") |
| 124 | + op.drop_index( |
| 125 | + op.f("ix_documenttagrecommendation_user_id"), |
| 126 | + table_name="documenttagrecommendation", |
| 127 | + ) |
| 128 | + op.drop_index( |
| 129 | + op.f("ix_documenttagrecommendation_task_id"), |
| 130 | + table_name="documenttagrecommendation", |
| 131 | + ) |
| 132 | + op.drop_index( |
| 133 | + op.f("ix_documenttagrecommendation_project_id"), |
| 134 | + table_name="documenttagrecommendation", |
| 135 | + ) |
| 136 | + op.drop_index( |
| 137 | + op.f("ix_documenttagrecommendation_model_name"), |
| 138 | + table_name="documenttagrecommendation", |
| 139 | + ) |
| 140 | + op.drop_index( |
| 141 | + op.f("ix_documenttagrecommendation_created"), |
| 142 | + table_name="documenttagrecommendation", |
| 143 | + ) |
| 144 | + op.drop_table("documenttagrecommendation") |
| 145 | + # ### end Alembic commands ### |
0 commit comments