diff options
Diffstat (limited to 'rust')
-rw-r--r-- | rust/migrations/2018-05-12-001226_init/up.sql | 16 | ||||
-rw-r--r-- | rust/src/database_schema.rs | 39 |
2 files changed, 27 insertions, 28 deletions
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 -> Timestamp, } } table! { container_edit (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, ident_id -> Uuid, rev_id -> Nullable<Int8>, redirect_id -> Nullable<Uuid>, @@ -29,8 +29,8 @@ table! { table! { container_rev (id) { id -> Int8, - extra_json -> Nullable<Json>, - name -> Nullable<Text>, + extra_json -> Nullable<Jsonb>, + name -> Text, parent_ident_id -> Nullable<Int8>, publisher -> Nullable<Text>, issn -> Nullable<Text>, @@ -40,7 +40,7 @@ table! { table! { creator_edit (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, ident_id -> Uuid, rev_id -> Nullable<Int8>, redirect_id -> Nullable<Uuid>, @@ -60,8 +60,8 @@ table! { table! { creator_rev (id) { id -> Int8, - extra_json -> Nullable<Json>, - name -> Nullable<Text>, + extra_json -> Nullable<Jsonb>, + name -> Text, orcid -> Nullable<Text>, } } @@ -69,7 +69,7 @@ table! { table! { editgroup (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, editor_id -> Int8, description -> Nullable<Text>, } @@ -87,7 +87,7 @@ table! { table! { file_edit (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, ident_id -> Uuid, rev_id -> Nullable<Int8>, redirect_id -> Nullable<Uuid>, @@ -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<Json>, + extra_json -> Nullable<Jsonb>, size -> Nullable<Int4>, sha1 -> Nullable<Text>, url -> Nullable<Text>, @@ -135,7 +134,7 @@ table! { table! { release_edit (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, ident_id -> Uuid, rev_id -> Nullable<Int8>, redirect_id -> Nullable<Uuid>, @@ -165,12 +164,12 @@ table! { table! { release_rev (id) { id -> Int8, - extra_json -> Nullable<Json>, - work_ident_id -> Nullable<Uuid>, + extra_json -> Nullable<Jsonb>, + work_ident_id -> Uuid, container_ident_id -> Nullable<Uuid>, - title -> Nullable<Text>, + title -> Text, license -> Nullable<Text>, - release_type -> Nullable<Text>, + release_type -> Text, date -> Nullable<Text>, doi -> Nullable<Text>, volume -> Nullable<Text>, @@ -182,7 +181,7 @@ table! { table! { work_edit (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, ident_id -> Uuid, rev_id -> Nullable<Int8>, redirect_id -> Nullable<Uuid>, @@ -202,7 +201,7 @@ table! { table! { work_rev (id) { id -> Int8, - extra_json -> Nullable<Json>, + extra_json -> Nullable<Jsonb>, work_type -> Nullable<Text>, primary_release_id -> Nullable<Uuid>, } @@ -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)); |