From 1e359932c4923de7da067772348c0ac933c42331 Mon Sep 17 00:00:00 2001 From: Spyros Date: Tue, 24 Oct 2023 16:22:21 +0100 Subject: [PATCH] migration --- ...2946f9_cache_gap_analysis_results_in_db.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 migrations/versions/5029c02946f9_cache_gap_analysis_results_in_db.py diff --git a/migrations/versions/5029c02946f9_cache_gap_analysis_results_in_db.py b/migrations/versions/5029c02946f9_cache_gap_analysis_results_in_db.py new file mode 100644 index 000000000..7eeafb7f1 --- /dev/null +++ b/migrations/versions/5029c02946f9_cache_gap_analysis_results_in_db.py @@ -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 ###