- import all enums for database migrations (check constraints)
All checks were successful
CI Pipeline / japa-tests (push) Successful in 55s
All checks were successful
CI Pipeline / japa-tests (push) Successful in 55s
- npm updates
This commit is contained in:
parent
6fa22aad9b
commit
3ea2e8ca94
7 changed files with 212 additions and 76 deletions
|
@ -19,7 +19,7 @@ export default class Documents extends BaseSchema {
|
|||
.inTable('projects')
|
||||
.onDelete('NO ACTION') // don't delete this doc when project is deleted
|
||||
.onUpdate('NO ACTION');
|
||||
table.enum('type', Object.values(DatasetTypes)).notNullable();
|
||||
table.enum('type', Object.keys(DatasetTypes)).notNullable();
|
||||
table.string('language').notNullable();
|
||||
table.enum('server_state', Object.values(ServerStates)).notNullable().defaultTo("'inprogress'");
|
||||
table.boolean('belongs_to_bibliography').notNullable().defaultTo(false);
|
||||
|
|
51
database/migrations/references_1_document_references.ts
Normal file
51
database/migrations/references_1_document_references.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
|
||||
import { RelationTypes, ReferenceIdentifierTypes } from 'Contracts/enums';
|
||||
|
||||
export default class DocumentReferences extends BaseSchema {
|
||||
protected tableName = 'document_references';
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary().defaultTo("nextval('document_references_id_seq')");
|
||||
table.integer('document_id').unsigned().notNullable();
|
||||
table
|
||||
.foreign('document_id', 'document_references_document_id_foreign')
|
||||
.references('id')
|
||||
.inTable('documents')
|
||||
.onDelete('CASCADE') // delete this reference when document is deleted
|
||||
.onUpdate('CASCADE');
|
||||
// table.string('type').notNullable();
|
||||
table.enum('type', Object.keys(ReferenceIdentifierTypes)).notNullable();
|
||||
// table.string('relation').notNullable();
|
||||
table.enum('relation', Object.keys(RelationTypes)).notNullable();
|
||||
table.string('value').notNullable();
|
||||
table.string('label').notNullable();
|
||||
table.timestamp('created_at', { useTz: false }).nullable();
|
||||
table.timestamp('updated_at', { useTz: false }).nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
// -- Table: document_references
|
||||
// CREATE TABLE IF NOT EXISTS document_references
|
||||
// (
|
||||
// id integer NOT NULL DEFAULT nextval('document_references_id_seq'::regclass),
|
||||
// document_id integer NOT NULL,
|
||||
// type character varying(255) NOT NULL,
|
||||
// relation character varying(255) NOT NULL,
|
||||
// value character varying(255) NOT NULL,
|
||||
// label character varying(255) NOT NULL,
|
||||
// created_at timestamp(0) without time zone,
|
||||
// updated_at timestamp(0) without time zone,
|
||||
// CONSTRAINT document_references_pkey PRIMARY KEY (id),
|
||||
// CONSTRAINT document_references_document_id_foreign FOREIGN KEY (document_id)
|
||||
// REFERENCES documents (id) MATCH SIMPLE
|
||||
// ON UPDATE CASCADE
|
||||
// ON DELETE CASCADE,
|
||||
// CONSTRAINT document_references_relation_check CHECK (relation::text = ANY (ARRAY['IsSupplementTo'::character varying::text, 'IsSupplementedBy'::character varying::text, 'IsContinuedBy'::character varying::text, 'Continues'::character varying::text, 'IsNewVersionOf'::character varying::text, 'IsPartOf'::character varying::text, 'HasPart'::character varying::text, 'Compiles'::character varying::text, 'IsVariantFormOf'::character varying::text])),
|
||||
// CONSTRAINT document_references_type_check CHECK (type::text = ANY (ARRAY['DOI'::character varying::text, 'Handle'::character varying::text, 'ISBN'::character varying::text, 'ISSN'::character varying::text, 'URL'::character varying::text, 'URN'::character varying::text]))
|
||||
// )
|
45
database/migrations/references_2_document_identifiers.ts
Normal file
45
database/migrations/references_2_document_identifiers.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
|
||||
import { IdentifierTypes } from 'Contracts/enums';
|
||||
|
||||
export default class DocumentIdentifiers extends BaseSchema {
|
||||
protected tableName = 'document_identifiers';
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').primary().defaultTo("nextval('document_identifiers_id_seq')")
|
||||
table.integer('document_id').unsigned().notNullable();
|
||||
table
|
||||
.foreign('document_id', 'document_identifiers_document_id_foreign')
|
||||
.references('id')
|
||||
.inTable('documents')
|
||||
.onDelete('CASCADE') // delete this identifier when document is deleted
|
||||
.onUpdate('CASCADE');
|
||||
// table.string('type').notNullable();
|
||||
table.enum('type', Object.keys(IdentifierTypes)).notNullable();
|
||||
table.string('value').notNullable();
|
||||
table.timestamp('created_at', { useTz: false }).nullable();
|
||||
table.timestamp('updated_at', { useTz: false }).nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
// -- Table: document_identifiers
|
||||
// CREATE TABLE IF NOT EXISTS document_identifiers
|
||||
// (
|
||||
// id integer NOT NULL DEFAULT nextval('document_identifiers_id_seq'::regclass),
|
||||
// document_id integer NOT NULL,
|
||||
// type character varying(255) NOT NULL,
|
||||
// value character varying(255) NOT NULL,
|
||||
// created_at timestamp(0) without time zone,
|
||||
// updated_at timestamp(0) without time zone,
|
||||
// CONSTRAINT document_identifiers_pkey PRIMARY KEY (id),
|
||||
// CONSTRAINT document_identifiers_document_id_foreign FOREIGN KEY (document_id)
|
||||
// REFERENCES documents (id) MATCH SIMPLE
|
||||
// ON UPDATE CASCADE
|
||||
// ON DELETE CASCADE,
|
||||
// CONSTRAINT document_identifiers_type_check CHECK (type::text = ANY (ARRAY['doi'::character varying::text, 'handle'::character varying::text, 'isbn'::character varying::text, 'issn'::character varying::text, 'url'::character varying::text, 'urn'::character varying::text]))
|
||||
// )
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue