From 98206c528275be4bb2ea6b715d6176877b5bdde7 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Wed, 21 Aug 2024 19:55:24 +0000 Subject: [PATCH] Fixup migrations --- ...f1f5e7b3_rollback_attestation_migration.py | 32 +++++++++++++ .../7f0c9f105f44_create_attestations_table.py | 46 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 warehouse/migrations/versions/7ca0f1f5e7b3_rollback_attestation_migration.py create mode 100644 warehouse/migrations/versions/7f0c9f105f44_create_attestations_table.py diff --git a/warehouse/migrations/versions/7ca0f1f5e7b3_rollback_attestation_migration.py b/warehouse/migrations/versions/7ca0f1f5e7b3_rollback_attestation_migration.py new file mode 100644 index 000000000000..31a1b5636bf4 --- /dev/null +++ b/warehouse/migrations/versions/7ca0f1f5e7b3_rollback_attestation_migration.py @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Rollback attestation migration + +Revision ID: 7ca0f1f5e7b3 +Revises: 7f0c9f105f44 +Create Date: 2024-08-21 19:52:40.084048 +""" + + +from alembic import op + +revision = "7ca0f1f5e7b3" +down_revision = "7f0c9f105f44" + + +def upgrade(): + op.drop_table("attestation") + + +def downgrade(): + pass diff --git a/warehouse/migrations/versions/7f0c9f105f44_create_attestations_table.py b/warehouse/migrations/versions/7f0c9f105f44_create_attestations_table.py new file mode 100644 index 000000000000..c86d454ddc5a --- /dev/null +++ b/warehouse/migrations/versions/7f0c9f105f44_create_attestations_table.py @@ -0,0 +1,46 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +create Attestations table +Revision ID: 7f0c9f105f44 +Revises: 26455e3712a2 +Create Date: 2024-07-25 15:49:01.993869 +""" + +import sqlalchemy as sa + +from alembic import op +from sqlalchemy.dialects import postgresql + +revision = "7f0c9f105f44" +down_revision = "26455e3712a2" + + +def upgrade(): + op.create_table( + "attestation", + sa.Column("file_id", sa.UUID(), nullable=False), + sa.Column( + "attestation_file_blake2_digest", postgresql.CITEXT(), nullable=False + ), + sa.Column( + "id", sa.UUID(), server_default=sa.text("gen_random_uuid()"), nullable=False + ), + sa.ForeignKeyConstraint( + ["file_id"], ["release_files.id"], onupdate="CASCADE", ondelete="CASCADE" + ), + sa.PrimaryKeyConstraint("id"), + ) + + +def downgrade(): + op.drop_table("attestation")