Skip to content

Commit

Permalink
migration
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Oct 24, 2023
1 parent 48f6e0d commit 1e35993
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""cache gap analysis results in db
Revision ID: 5029c02946f9
Revises: fffdc0652e27
Create Date: 2023-10-24 09:02:37.535867
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "5029c02946f9"
down_revision = "fffdc0652e27"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"gap_analysis_results",
sa.Column("cache_key", sa.String(), nullable=False),
sa.Column("ga_object", sa.String(), nullable=True),
sa.PrimaryKeyConstraint("cache_key", name=op.f("pk_gap_analysis_results")),
sa.UniqueConstraint("cache_key", name="unique_cache_key_field"),
)
with op.batch_alter_table("embeddings", schema=None) as batch_op:
batch_op.alter_column(
"embeddings_url", existing_type=sa.VARCHAR(), nullable=True
)
batch_op.alter_column(
"embeddings_content", existing_type=sa.VARCHAR(), nullable=True
)
batch_op.create_foreign_key(
batch_op.f("fk_embeddings_cre_id_cre"),
"cre",
["cre_id"],
["id"],
onupdate="CASCADE",
ondelete="CASCADE",
)
batch_op.create_foreign_key(
batch_op.f("fk_embeddings_node_id_node"),
"node",
["node_id"],
["id"],
onupdate="CASCADE",
ondelete="CASCADE",
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("embeddings", schema=None) as batch_op:
batch_op.drop_constraint(
batch_op.f("fk_embeddings_node_id_node"), type_="foreignkey"
)
batch_op.drop_constraint(
batch_op.f("fk_embeddings_cre_id_cre"), type_="foreignkey"
)
batch_op.alter_column(
"embeddings_content", existing_type=sa.VARCHAR(), nullable=False
)
batch_op.alter_column(
"embeddings_url", existing_type=sa.VARCHAR(), nullable=False
)

op.drop_table("gap_analysis_results")
# ### end Alembic commands ###

0 comments on commit 1e35993

Please sign in to comment.