diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-14 11:08:07 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-14 12:47:03 +0100 |
commit | 182d1454eb5f2bde86ef2256bb945bc41ee45be5 (patch) | |
tree | 94c6f1ef785993cd5a438b5d702d70a8742e482b /migrations/2020-12-14-113756_artifact_not_unique_by_path | |
parent | 98a227248449e71f08cc7ff80579978bf0e5440e (diff) |
Fix: Add constraints that artifact entries must be unique by path and job id
This patch alters the database so that artifact entries in the db are
unique by path and job they belong to.
The `db::models::Artifact` implementation was updated to select the
newly created Artifact object by path and by job id.
The uniqueness constraint on the `path` column in the `artifacts` table
was dropped.
Uncool: We did not generate the constraint name explicitely. That's
unfortunate as we have to gamble here that the constraint name is always
guaranteed to be the same ("artifacts_path_key").
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'migrations/2020-12-14-113756_artifact_not_unique_by_path')
-rw-r--r-- | migrations/2020-12-14-113756_artifact_not_unique_by_path/down.sql | 7 | ||||
-rw-r--r-- | migrations/2020-12-14-113756_artifact_not_unique_by_path/up.sql | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/migrations/2020-12-14-113756_artifact_not_unique_by_path/down.sql b/migrations/2020-12-14-113756_artifact_not_unique_by_path/down.sql new file mode 100644 index 0000000..c8bfe9d --- /dev/null +++ b/migrations/2020-12-14-113756_artifact_not_unique_by_path/down.sql @@ -0,0 +1,7 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE + artifacts +ADD CONSTRAINT + artifacts_path_key -- as generated by default for postgresql + UNIQUE (path) + diff --git a/migrations/2020-12-14-113756_artifact_not_unique_by_path/up.sql b/migrations/2020-12-14-113756_artifact_not_unique_by_path/up.sql new file mode 100644 index 0000000..0dee2b4 --- /dev/null +++ b/migrations/2020-12-14-113756_artifact_not_unique_by_path/up.sql @@ -0,0 +1,5 @@ +-- Your SQL goes here +ALTER TABLE + artifacts +DROP CONSTRAINT + artifacts_path_key -- as generated by default for postgresql |