diff --git a/backend/k8s/db.yaml b/backend/k8s/db.yaml index 8c498e01..5475f6b6 100644 --- a/backend/k8s/db.yaml +++ b/backend/k8s/db.yaml @@ -54,7 +54,7 @@ spec: claimName: test-observer-db containers: - name: test-observer-db - image: postgres:15.2 + image: postgres:14 volumeMounts: - name: test-observer-db mountPath: /var/lib/postgresql/data diff --git a/backend/migrations/versions/2023_06_20_1000-b33ee8dd41b1_use_nulls_not_distinct.py b/backend/migrations/versions/2023_06_20_1000-b33ee8dd41b1_use_nulls_not_distinct.py deleted file mode 100644 index d82cf95d..00000000 --- a/backend/migrations/versions/2023_06_20_1000-b33ee8dd41b1_use_nulls_not_distinct.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Use nulls not distinct - -Revision ID: b33ee8dd41b1 -Revises: 6a80dad01d24 -Create Date: 2023-06-20 10:00:07.676129+00:00 - -""" -from alembic import op - - -# revision identifiers, used by Alembic. -revision = "b33ee8dd41b1" -down_revision = "6a80dad01d24" -branch_labels = None -depends_on = None - - -def upgrade() -> None: - op.execute( - "ALTER TABLE artefact_build " - "DROP CONSTRAINT IF EXISTS artefact_build_artefact_id_architecture_revision_key" - ", ADD CONSTRAINT unique_artefact_build " - "UNIQUE NULLS NOT DISTINCT (artefact_id, architecture, revision);" - ) - - -def downgrade() -> None: - op.execute( - "ALTER TABLE artefact_build " - "DROP CONSTRAINT IF EXISTS unique_artefact_build" - ", ADD CONSTRAINT artefact_build_artefact_id_architecture_revision_key " - "UNIQUE (artefact_id, architecture, revision);" - ) diff --git a/backend/migrations/versions/2023_07_11_1148-158244992900_disallow_multiple_artefact_builds_with_.py b/backend/migrations/versions/2023_07_11_1148-158244992900_disallow_multiple_artefact_builds_with_.py new file mode 100644 index 00000000..ac0b636b --- /dev/null +++ b/backend/migrations/versions/2023_07_11_1148-158244992900_disallow_multiple_artefact_builds_with_.py @@ -0,0 +1,32 @@ +"""disallow multiple artefact builds with null revision + +Revision ID: 158244992900 +Revises: b33ee8dd41b1 +Create Date: 2023-07-11 11:48:49.777726+00:00 + +""" +from alembic import op + + +# revision identifiers, used by Alembic. +revision = "158244992900" +down_revision = "6a80dad01d24" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.create_index( + "unique_artefact_build_null_revision", + "artefact_build", + ["artefact_id", "architecture"], + unique=True, + postgresql_where=("revision IS NULL"), + ) + + +def downgrade() -> None: + op.drop_index( + "unique_artefact_build_null_revision", + "artefact_build", + )