From cd214b3ecde57c891537ff27edfde18b773dfe46 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 18:55:33 -0700 Subject: update schema --- rust/migrations/2018-05-12-001226_init/up.sql | 16 +++++------ rust/src/database_schema.rs | 39 +++++++++++++-------------- 2 files changed, 27 insertions(+), 28 deletions(-) (limited to 'rust') diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index a517d788..0c62bc07 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -29,7 +29,7 @@ ALTER TABLE editor CREATE TABLE changelog ( id BIGSERIAL PRIMARY KEY, editgroup_id BIGINT REFERENCES editgroup(id) NOT NULL, - timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now() + timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL ); -------------------- Creators ----------------------------------------------- @@ -37,7 +37,7 @@ CREATE TABLE creator_rev ( id BIGSERIAL PRIMARY KEY, extra_json JSONB, - name TEXT, + name TEXT NOT NULL, orcid TEXT ); @@ -66,7 +66,7 @@ CREATE TABLE container_rev ( id BIGSERIAL PRIMARY KEY, extra_json JSONB, - name TEXT, + name TEXT NOT NULL, parent_ident_id BIGINT REFERENCES container_rev(id), publisher TEXT, issn TEXT -- TODO: varchar @@ -119,11 +119,11 @@ CREATE TABLE release_rev ( id BIGSERIAL PRIMARY KEY, extra_json JSONB, - work_ident_id UUID, -- FOREIGN KEY; see ALRTER below + work_ident_id UUID NOT NULL, -- FOREIGN KEY; see ALRTER below container_ident_id UUID REFERENCES container_ident(id), - title TEXT, + title TEXT NOT NULL, license TEXT, -- TODO: ? - release_type TEXT, -- TODO: enum + release_type TEXT NOT NULL, -- TODO: enum date TEXT, -- XXX: datetime doi TEXT, -- TODO: identifier table? volume TEXT, @@ -189,11 +189,11 @@ CREATE TABLE release_contrib ( ); CREATE TABLE release_ref ( + id BIGSERIAL PRIMARY KEY, release_rev BIGSERIAL REFERENCES release_rev(id) NOT NULL, - target_release_ident_id UUID REFERENCES creator_ident(id), + target_release_ident_id UUID REFERENCES release_ident(id), -- or work? index INTEGER, stub TEXT - PRIMARY KEY (release_rev, target_release_ident_id) ); CREATE TABLE file_release ( diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs index 83e7f7d0..80f8fb3f 100644 --- a/rust/src/database_schema.rs +++ b/rust/src/database_schema.rs @@ -2,14 +2,14 @@ table! { changelog (id) { id -> Int8, editgroup_id -> Int8, - timestamp -> Nullable, + timestamp -> Timestamp, } } table! { container_edit (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, ident_id -> Uuid, rev_id -> Nullable, redirect_id -> Nullable, @@ -29,8 +29,8 @@ table! { table! { container_rev (id) { id -> Int8, - extra_json -> Nullable, - name -> Nullable, + extra_json -> Nullable, + name -> Text, parent_ident_id -> Nullable, publisher -> Nullable, issn -> Nullable, @@ -40,7 +40,7 @@ table! { table! { creator_edit (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, ident_id -> Uuid, rev_id -> Nullable, redirect_id -> Nullable, @@ -60,8 +60,8 @@ table! { table! { creator_rev (id) { id -> Int8, - extra_json -> Nullable, - name -> Nullable, + extra_json -> Nullable, + name -> Text, orcid -> Nullable, } } @@ -69,7 +69,7 @@ table! { table! { editgroup (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, editor_id -> Int8, description -> Nullable, } @@ -87,7 +87,7 @@ table! { table! { file_edit (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, ident_id -> Uuid, rev_id -> Nullable, redirect_id -> Nullable, @@ -105,8 +105,7 @@ table! { } table! { - file_release (id) { - id -> Int8, + file_release (file_rev, target_release_ident_id) { file_rev -> Int8, target_release_ident_id -> Uuid, } @@ -115,7 +114,7 @@ table! { table! { file_rev (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, size -> Nullable, sha1 -> Nullable, url -> Nullable, @@ -135,7 +134,7 @@ table! { table! { release_edit (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, ident_id -> Uuid, rev_id -> Nullable, redirect_id -> Nullable, @@ -165,12 +164,12 @@ table! { table! { release_rev (id) { id -> Int8, - extra_json -> Nullable, - work_ident_id -> Nullable, + extra_json -> Nullable, + work_ident_id -> Uuid, container_ident_id -> Nullable, - title -> Nullable, + title -> Text, license -> Nullable, - release_type -> Nullable, + release_type -> Text, date -> Nullable, doi -> Nullable, volume -> Nullable, @@ -182,7 +181,7 @@ table! { table! { work_edit (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, ident_id -> Uuid, rev_id -> Nullable, redirect_id -> Nullable, @@ -202,7 +201,7 @@ table! { table! { work_rev (id) { id -> Int8, - extra_json -> Nullable, + extra_json -> Nullable, work_type -> Nullable, primary_release_id -> Nullable, } @@ -225,7 +224,7 @@ joinable!(release_contrib -> release_rev (release_rev)); joinable!(release_edit -> editgroup (editgroup_id)); joinable!(release_edit -> release_rev (rev_id)); joinable!(release_ident -> release_rev (rev_id)); -joinable!(release_ref -> creator_ident (target_release_ident_id)); +joinable!(release_ref -> release_ident (target_release_ident_id)); joinable!(release_ref -> release_rev (release_rev)); joinable!(release_rev -> container_ident (container_ident_id)); joinable!(release_rev -> work_ident (work_ident_id)); -- cgit v1.2.3