diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-01-07 15:19:12 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-01-14 13:29:26 +0100 |
commit | 023421f8c91a1e1ab36d6dbfa989dcbafdd59de4 (patch) | |
tree | 8c7c91c3ec05bb4fd7ffc6e94231289c40a7bc04 | |
parent | b6a52fd28003ed3ce251a3647e837ca11b9d1222 (diff) |
Add migration for dedicated release table
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r-- | migrations/2021-01-07-122618_dedicated-releases-table/down.sql | 7 | ||||
-rw-r--r-- | migrations/2021-01-07-122618_dedicated-releases-table/up.sql | 13 | ||||
-rw-r--r-- | src/schema.rs | 11 |
3 files changed, 30 insertions, 1 deletions
diff --git a/migrations/2021-01-07-122618_dedicated-releases-table/down.sql b/migrations/2021-01-07-122618_dedicated-releases-table/down.sql new file mode 100644 index 0000000..3eaa8b9 --- /dev/null +++ b/migrations/2021-01-07-122618_dedicated-releases-table/down.sql @@ -0,0 +1,7 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE + artifacts +ADD COLUMN + released boolean NOT NULL; + +DROP TABLE releases; diff --git a/migrations/2021-01-07-122618_dedicated-releases-table/up.sql b/migrations/2021-01-07-122618_dedicated-releases-table/up.sql new file mode 100644 index 0000000..0fd2295 --- /dev/null +++ b/migrations/2021-01-07-122618_dedicated-releases-table/up.sql @@ -0,0 +1,13 @@ +-- Your SQL goes here +ALTER TABLE + artifacts +DROP COLUMN + released; + +CREATE TABLE releases ( + id SERIAL PRIMARY KEY NOT NULL, + artifact_id INTEGER REFERENCES artifacts(id) NOT NULL, + release_date TIMESTAMP WITH TIME ZONE NOT NULL, + + CONSTRAINT UC_art_release_unique UNIQUE (artifact_id, release_date) +); diff --git a/src/schema.rs b/src/schema.rs index 85e9266..7aac78a 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -12,7 +12,6 @@ table! { artifacts (id) { id -> Int4, path -> Varchar, - released -> Bool, job_id -> Int4, } } @@ -93,6 +92,14 @@ table! { } table! { + releases (id) { + id -> Int4, + artifact_id -> Int4, + release_date -> Timestamptz, + } +} + +table! { submit_envs (id) { id -> Int4, submit_id -> Int4, @@ -123,6 +130,7 @@ joinable!(jobs -> endpoints (endpoint_id)); joinable!(jobs -> images (image_id)); joinable!(jobs -> packages (package_id)); joinable!(jobs -> submits (submit_id)); +joinable!(releases -> artifacts (artifact_id)); joinable!(submit_envs -> envvars (env_id)); joinable!(submit_envs -> submits (submit_id)); joinable!(submits -> githashes (repo_hash_id)); @@ -140,6 +148,7 @@ allow_tables_to_appear_in_same_query!( job_output_artifacts, jobs, packages, + releases, submit_envs, submits, ); |