- add all migration files for database

- npm updates
This commit is contained in:
Kaimbacher 2023-04-24 13:03:36 +02:00
parent 8a404e8a0c
commit 4abcfe7135
29 changed files with 1540 additions and 375 deletions

View file

@ -1,21 +1,16 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import Config from '@ioc:Adonis/Core/Config';
export default class Roles extends BaseSchema {
protected tableName = Config.get('rolePermission.role_table', 'roles');
protected tableName = 'roles';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id');
table.string('name', 191).unique();
table.string('slug', 191).nullable().unique();
table.string('description', 191).nullable();
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true }).nullable();
table.timestamp('updated_at', { useTz: true }).nullable();
table.increments('id').primary().defaultTo("nextval('roles_id_seq')");
table.string('name', 255).notNullable();
table.string('display_name', 255);
table.string('description', 255);
table.timestamp('created_at', { useTz: false }).nullable();
table.timestamp('updated_at', { useTz: false }).nullable();
});
}
@ -23,3 +18,19 @@ export default class Roles extends BaseSchema {
this.schema.dropTable(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS roles
// (
// id integer NOT NULL DEFAULT nextval('roles_id_seq'::regclass),
// name character varying(255) NOT NULL,
// display_name character varying(255),
// description character varying(255),
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT roles_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS roles
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE roles FROM tethys_app;
// GRANT ALL ON TABLE roles TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE roles TO tethys_app;

View file

@ -1,25 +1,39 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
import Config from '@ioc:Adonis/Core/Config'
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class Permissions extends BaseSchema {
protected tableName = Config.get('rolePermission.permission_table', 'permissions')
protected tableName = 'permissions';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('name', 191).unique()
table.string('slug', 191).nullable().unique()
table.string('description', 191).nullable()
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('permissions_id_seq')");
table.string('name', 255).unique().notNullable();
table.string('display_name', 100).notNullable();
table.string('description', 255);
// table.timestamp('created_at');
// table.timestamp('updated_at');
table.timestamp('created_at', { useTz: false });
table.timestamp('updated_at', { useTz: false });
});
}
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true }).nullable()
table.timestamp('updated_at', { useTz: true }).nullable()
})
}
public async down() {
this.schema.dropTable(this.tableName)
}
public async down() {
this.schema.dropTableIfExists(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS permissions
// (
// id integer NOT NULL DEFAULT nextval('permissions_id_seq'::regclass),
// name character varying(255) NOT NULL,
// display_name character varying(100) NOT NULL,
// description character varying(255),
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT permissions_pkey PRIMARY KEY (id),
// CONSTRAINT permissions_name_unique UNIQUE (name)
// )
// ALTER TABLE IF EXISTS permissions
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE permissions FROM tethys_app;
// GRANT ALL ON TABLE permissions TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE permissions TO tethys_app;

View file

@ -0,0 +1,52 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class RoleHasPermissions extends BaseSchema {
// protected tableName = Config.get('rolePermission.role_permission_table', 'role_permissions')
protected tableName = 'role_has_permissions';
public async up() {
this.schema.createTable(this.tableName, (table) => {
// table.integer('permission_id').notNullable();
// table.integer('role_id').notNullable();
table.integer('permission_id').unsigned().index().notNullable();
table
.foreign('permission_id', 'role_has_permissions_permission_id_foreign')
.references('id')
.inTable('permissions')
.onDelete('CASCADE') // delete this when permission is deleted
.onUpdate('CASCADE');
table.integer('role_id').unsigned().index().notNullable();
table
.foreign('role_id', 'role_has_permissions_role_id_foreign')
.references('id')
.inTable('roles')
.onDelete('CASCADE') // delete this when role is deleted
.onUpdate('CASCADE');
table.primary(['permission_id', 'role_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS role_has_permissions
// (
// permission_id integer NOT NULL,
// role_id integer NOT NULL,
// CONSTRAINT role_has_permissions_pkey PRIMARY KEY (permission_id, role_id),
// CONSTRAINT role_has_permissions_permission_id_foreign FOREIGN KEY (permission_id)
// REFERENCES permissions (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT role_has_permissions_role_id_foreign FOREIGN KEY (role_id)
// REFERENCES roles (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS role_has_permissions
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE role_has_permissions FROM tethys_app;
// GRANT ALL ON TABLE role_has_permissions TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE role_has_permissions TO tethys_app;

View file

@ -1,32 +0,0 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
import Config from '@ioc:Adonis/Core/Config'
export default class RolePermissions extends BaseSchema {
protected tableName = Config.get('rolePermission.role_permission_table', 'role_permissions')
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.integer('role_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.role_table', 'roles'))
table
.integer('permission_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.permission_table', 'permissions'))
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true }).nullable()
table.timestamp('updated_at', { useTz: true }).nullable()
})
}
public async down() {
this.schema.dropTable(this.tableName)
}
}

View file

@ -0,0 +1,43 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class Accounts extends BaseSchema {
protected tableName = 'accounts';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('accounts_id_seq')");
table.string('login', 20).notNullable();
table.string('password', 60).notNullable();
table.string('email', 255).unique().notNullable();
table.string('first_name', 255).nullable();
table.string('last_name', 255).nullable();
table.string('remember_token');
table.timestamp('created_at');
table.timestamp('updated_at');
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS accounts
// (
// id integer NOT NULL DEFAULT nextval('accounts_id_seq'::regclass),
// login character varying(20) NOT NULL,
// password character varying(60) NOT NULL,
// email character varying(255) NOT NULL,
// first_name character varying(255),
// last_name character varying(255),
// remember_token character varying(100),
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT accounts_pkey PRIMARY KEY (id),
// CONSTRAINT accounts_email_unique UNIQUE (email)
// )
// ALTER TABLE IF EXISTS accounts
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE accounts FROM tethys_app;
// GRANT ALL ON TABLE accounts TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE accounts TO tethys_app;

View file

@ -1,32 +0,0 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
import Config from '@ioc:Adonis/Core/Config'
export default class UserPermissions extends BaseSchema {
protected tableName = Config.get('rolePermission.user_permission_table', 'user_permissions')
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.integer('user_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.user_table', 'users'))
table
.integer('permission_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.permission_table', 'permissions'))
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true }).nullable()
table.timestamp('updated_at', { useTz: true }).nullable()
})
}
public async down() {
this.schema.dropTable(this.tableName)
}
}

View file

@ -0,0 +1,52 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class LinkAccountsRoles extends BaseSchema {
// protected tableName = Config.get('rolePermission.user_role_table', 'user_roles')
protected tableName = 'link_accounts_roles';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('account_id').index().unsigned().notNullable();
table
.foreign('account_id', 'link_accounts_roles_account_id_foreign')
.references('id')
.inTable('accounts')
// .inTable(Config.get('rolePermission.user_table', 'users'))
.onDelete('CASCADE') // delete this when account is delete
.onUpdate('CASCADE');
table.integer('role_id').index().unsigned().notNullable();
table
.foreign('role_id', 'link_accounts_roles_role_id_foreign')
.references('id')
.inTable('roles')
// .inTable(Config.get('rolePermission.role_table', 'roles'))
.onDelete('CASCADE') // delete this when account is delete
.onUpdate('CASCADE');
table.primary(['account_id', 'role_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// CREATE TABLE IF NOT EXISTS link_accounts_roles
// (
// account_id integer NOT NULL,
// role_id integer NOT NULL,
// CONSTRAINT link_accounts_roles_pkey PRIMARY KEY (account_id, role_id),
// CONSTRAINT link_accounts_roles_account_id_foreign FOREIGN KEY (account_id)
// REFERENCES accounts (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT link_accounts_roles_role_id_foreign FOREIGN KEY (role_id)
// REFERENCES roles (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS link_accounts_roles
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE link_accounts_roles FROM tethys_app;
// GRANT ALL ON TABLE link_accounts_roles TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE link_accounts_roles TO tethys_app;

View file

@ -1,32 +0,0 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
import Config from '@ioc:Adonis/Core/Config'
export default class UserRoles extends BaseSchema {
protected tableName = Config.get('rolePermission.user_role_table', 'user_roles')
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.integer('user_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.user_table', 'users'))
table
.integer('role_id')
.unsigned()
.references('id')
.inTable(Config.get('rolePermission.role_table', 'roles'))
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true }).nullable()
table.timestamp('updated_at', { useTz: true }).nullable()
})
}
public async down() {
this.schema.dropTable(this.tableName)
}
}

View file

@ -0,0 +1,80 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { PersonRoles, ContributorTypes } from 'Contracts/enums';
export default class LinkDocumentsPersons extends BaseSchema {
protected tableName = 'link_documents_persons';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('person_id').index('ix_fk_link_documents_persons_persons').notNullable();
table
.foreign('person_id', 'fk_link_documents_persons_persons')
.references('id')
.inTable('persons')
.onDelete('NO ACTION') // don't delete this when license is deleted
.onUpdate('NO ACTION');
table.integer('document_id').index('ix_fk_link_persons_documents_documents').notNullable();
table
.foreign('document_id', 'fk_link_persons_documents_documents')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this when document is deleted
.onUpdate('CASCADE');
// table.string('role').notNullable().defaultTo("'other'");
table.enum('role', Object.values(PersonRoles)).notNullable().defaultTo('other');
table.specificType('sort_order', 'smallint').notNullable();
table.boolean('allow_email_contact').notNullable().defaultTo(false);
// table.string('contributor_type');
table.enum('contributor_type', Object.values(ContributorTypes));
table.primary(['person_id', 'document_id', 'role']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: gba.link_documents_persons
// -- DROP TABLE IF EXISTS gba.link_documents_persons;
// CREATE TABLE IF NOT EXISTS link_documents_persons
// (
// person_id integer NOT NULL,
// document_id integer NOT NULL,
// role character varying(255) NOT NULL DEFAULT 'other'::character varying,
// sort_order smallint NOT NULL,
// allow_email_contact boolean NOT NULL DEFAULT false,
// contributor_type character varying(255),
// CONSTRAINT link_documents_persons_pkey PRIMARY KEY (person_id, document_id, role),
// CONSTRAINT fk_link_documents_persons_persons FOREIGN KEY (person_id)
// REFERENCES persons (id) MATCH SIMPLE
// ON UPDATE NO ACTION
// ON DELETE NO ACTION,
// CONSTRAINT fk_link_persons_documents_documents FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT link_documents_persons_contributor_type_check CHECK (contributor_type::text = ANY (ARRAY['ContactPerson'::character varying::text, 'DataCollector'::character varying::text, 'DataCurator'::character varying::text, 'DataManager'::character varying::text, 'Distributor'::character varying::text, 'Editor'::character varying::text, 'HostingInstitution'::character varying::text, 'Producer'::character varying::text, 'ProjectLeader'::character varying::text, 'ProjectManager'::character varying::text, 'ProjectMember'::character varying::text, 'RegistrationAgency'::character varying::text, 'RegistrationAuthority'::character varying::text, 'RelatedPerson'::character varying::text, 'Researcher'::character varying::text, 'ResearchGroup'::character varying::text, 'RightsHolder'::character varying::text, 'Sponsor'::character varying::text, 'Supervisor'::character varying::text, 'WorkPackageLeader'::character varying::text, 'Other'::character varying::text])),
// CONSTRAINT link_documents_persons_role_check CHECK (role::text = ANY (ARRAY['author'::character varying::text, 'contributor'::character varying::text, 'other'::character varying::text]))
// )
// ALTER TABLE IF EXISTS link_documents_persons
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE link_documents_persons FROM tethys_app;
// GRANT ALL ON TABLE link_documents_persons TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE link_documents_persons TO tethys_app;
// -- Index: ix_fk_link_documents_persons_persons
// -- DROP INDEX IF EXISTS ix_fk_link_documents_persons_persons;
// CREATE INDEX IF NOT EXISTS ix_fk_link_documents_persons_persons
// ON link_documents_persons USING btree
// (person_id ASC);
// -- Index: ix_fk_link_persons_documents_documents
// -- DROP INDEX IF EXISTS ix_fk_link_persons_documents_documents;
// CREATE INDEX IF NOT EXISTS ix_fk_link_persons_documents_documents
// ON link_documents_persons USING btree
// (document_id ASC);

View file

@ -0,0 +1,41 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { SubjectTypes } from 'Contracts/enums';
export default class DatasetSubjects extends BaseSchema {
protected tableName = 'dataset_subjects';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.bigIncrements('id').defaultTo("nextval('dataset_subjects_id_seq')");
table.string('language', 3);
// table.string('type', 255).notNullable().defaultTo('uncontrolled');
table.enum('type', Object.values(SubjectTypes)).defaultTo('uncontrolled');
table.string('value', 255).notNullable();
table.string('external_key', 255);
table.timestamp('created_at', { useTz: false }).nullable();
table.timestamp('updated_at', { useTz: false }).nullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: dataset_subjects
// CREATE TABLE IF NOT EXISTS dataset_subjects
// (
// id bigint NOT NULL DEFAULT nextval('dataset_subjects_id_seq'::regclass),
// language character varying(3),
// type character varying(255) NOT NULL,
// value character varying(255) NOT NULL,
// external_key character varying(255),
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT dataset_subjects_pkey PRIMARY KEY (id),
// CONSTRAINT dataset_subjects_type_check CHECK (type::text = 'uncontrolled'::text)
// )
// ALTER TABLE IF EXISTS dataset_subjects OWNER to tethys_admin;
// REVOKE ALL ON TABLE dataset_subjects FROM tethys_app;
// GRANT ALL ON TABLE dataset_subjects TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE dataset_subjects TO tethys_app;

View file

@ -0,0 +1,62 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class LinkDatasetSubjects extends BaseSchema {
protected tableName = 'link_dataset_subjects';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('subject_id').index('link_dataset_subjects_subject_id_index').notNullable();
table
.foreign('subject_id', 'link_dataset_subjects_subject_id_foreign')
.references('id')
.inTable('dataset_subjects')
.onDelete('NO ACTION') // don't delete this when subject is deleted
.onUpdate('NO ACTION');
table.integer('document_id').index('link_dataset_subjects_document_id_index').notNullable();
table
.foreign('document_id', 'link_dataset_subjects_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this when document is deleted
.onUpdate('CASCADE');
table.primary(['subject_id', 'document_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: link_dataset_subjects
// CREATE TABLE IF NOT EXISTS link_dataset_subjects
// (
// subject_id integer NOT NULL,
// document_id integer NOT NULL,
// CONSTRAINT link_dataset_subjects_pkey PRIMARY KEY (subject_id, document_id),
// CONSTRAINT link_dataset_subjects_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT link_dataset_subjects_subject_id_foreign FOREIGN KEY (subject_id)
// REFERENCES dataset_subjects (id) MATCH SIMPLE
// ON UPDATE NO ACTION
// ON DELETE NO ACTION
// )
// ALTER TABLE IF EXISTS .link_dataset_subjects
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE link_dataset_subjects FROM tethys_app;
// GRANT ALL ON TABLE link_dataset_subjects TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE link_dataset_subjects TO tethys_app;
// -- Index: link_dataset_subjects_document_id_index
// -- DROP INDEX IF EXISTS link_dataset_subjects_document_id_index;
// CREATE INDEX IF NOT EXISTS link_dataset_subjects_document_id_index
// ON link_dataset_subjects USING btree
// (document_id ASC);
// -- Index: link_dataset_subjects_subject_id_index
// -- DROP INDEX IF EXISTS link_dataset_subjects_subject_id_index;
// CREATE INDEX IF NOT EXISTS link_dataset_subjects_subject_id_index
// ON link_dataset_subjects USING btree
// (subject_id ASC);

View file

@ -0,0 +1,37 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class Projects extends BaseSchema {
protected tableName = 'projects';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('projects_id_seq')");
table.string('label', 50).notNullable();
table.string('name', 255).notNullable();
table.string('description', 255).nullable();
table.timestamp('created_at', { useTz: false }).nullable();
table.timestamp('updated_at', { useTz: false }).nullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: project
// CREATE TABLE IF NOT EXISTS projects
// (
// id integer NOT NULL DEFAULT nextval('projects_id_seq'::regclass),
// label character varying(50) NOT NULL,
// name character varying(255) NOT NULL,
// description character varying(2500),
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT projects_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS projects
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE projects FROM tethys_app;
// GRANT ALL ON TABLE projects TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE projects TO tethys_app;

View file

@ -0,0 +1,93 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { DatasetTypes, ServerStates } from 'Contracts/enums';
export default class Documents extends BaseSchema {
protected tableName = 'documents';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('documents_id_seq')");
table.string('contributing_corporation');
table.string('creating_corporation').notNullable();
table.string('publisher_name');
table.timestamp('embargo_date');
table.integer('publish_id').unique();
table.integer('project_id').unsigned().nullable();
table
.foreign('project_id', 'documents_project_id_foreign')
.references('id')
.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.string('language').notNullable();
table.enum('server_state', Object.values(ServerStates)).notNullable().defaultTo("'inprogress'");
table.boolean('belongs_to_bibliography').notNullable().defaultTo(false);
table.timestamp('created_at').notNullable();
table.timestamp('server_date_modified').notNullable();
table.timestamp('server_date_published');
table.integer('account_id').unsigned().nullable();
table
.foreign('account_id', 'documents_account_id_foreign')
.references('id')
.inTable('accounts')
.onDelete('NO ACTION') // don't delete this when account is deleted
.onUpdate('NO ACTION');
table.integer('editor_id');
table.integer('reviewer_id');
table.string('preferred_reviewer');
table.string('preferred_reviewer_email');
table.string('reject_editor_note');
table.string('reject_reviewer_note');
table.boolean('reviewer_note_visible').notNullable().defaultTo(false);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: documents
// CREATE TABLE IF NOT EXISTS documents
// (
// id integer NOT NULL DEFAULT nextval('documents_id_seq'::regclass),
// contributing_corporation character varying(255) ,
// creating_corporation character varying(255) NOT NULL,
// publisher_name character varying(255) ,
// embargo_date timestamp(0) without time zone,
// publish_id integer,
// project_id integer,
// type character varying(255) NOT NULL,
// language character varying(10) NOT NULL,
// server_state character varying(255) NOT NULL DEFAULT 'inprogress'::character varying,
// belongs_to_bibliography boolean NOT NULL DEFAULT false,
// created_at timestamp(0) without time zone NOT NULL,
// server_date_modified timestamp(0) without time zone NOT NULL,
// server_date_published timestamp(0) without time zone,
// account_id integer,
// editor_id integer,
// reviewer_id integer,
// preferred_reviewer character varying(25) ,
// preferred_reviewer_email character varying(50) ,
// reject_editor_note character varying(500) ,
// reject_reviewer_note character varying(500) ,
// reviewer_note_visible boolean NOT NULL DEFAULT false,
// CONSTRAINT documents_pkey PRIMARY KEY (id),
// CONSTRAINT documents_publish_id_unique UNIQUE (publish_id),
// CONSTRAINT documents_project_id_foreign FOREIGN KEY (project_id)
// REFERENCES projects (id) MATCH SIMPLE
// ON UPDATE NO ACTION
// ON DELETE NO ACTION,
// CONSTRAINT documents_account_id_foreign FOREIGN KEY (account_id)
// REFERENCES accounts (id) MATCH SIMPLE
// ON UPDATE NO ACTION
// ON DELETE NO ACTION,
// CONSTRAINT documents_server_state_check CHECK (server_state::text = ANY (ARRAY['deleted'::character varying::text, 'inprogress'::character varying::text, 'published'::character varying::text, 'released'::character varying::text, 'editor_accepted'::character varying::text, 'approved'::character varying::text, 'rejected_reviewer'::character varying::text, 'rejected_editor'::character varying::text, 'reviewed'::character varying::text])),
// CONSTRAINT documents_type_check CHECK (type::text = ANY (ARRAY['analysisdata'::character varying::text, 'measurementdata'::character varying::text, 'monitoring'::character varying::text, 'remotesensing'::character varying::text, 'gis'::character varying::text, 'models'::character varying::text, 'mixedtype'::character varying::text]))
// )
// ALTER TABLE IF EXISTS documents
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE documents FROM tethys_app;
// GRANT ALL ON TABLE documents TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE documents TO tethys_app;

View file

@ -0,0 +1,48 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { DescriptionTypes } from 'Contracts/enums';
export default class DatasetTitles extends BaseSchema {
protected tableName = 'dataset_abstracts';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('dataset_abstracts_id_seq')");
table.integer('document_id').unsigned().notNullable();
table
.foreign('document_id', 'dataset_abstracts_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this abstract when document is deleted
.onUpdate('CASCADE');
// table.string('type', 255).notNullable();
table.enum('type', Object.values(DescriptionTypes)).notNullable();
table.string('value', 255).notNullable();
table.string('language', 3).notNullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: dataset_titles
// CREATE TABLE IF NOT EXISTS dataset_titles
// (
// id integer NOT NULL DEFAULT nextval('dataset_titles_id_seq'::regclass),
// document_id integer NOT NULL,
// type character varying(255) NOT NULL,
// value character varying(255) NOT NULL,
// language character varying(3) NOT NULL,
// CONSTRAINT dataset_titles_pkey PRIMARY KEY (id),
// CONSTRAINT dataset_titles_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT dataset_titles_type_check CHECK (type::text = ANY (ARRAY['Main'::character varying::text, 'Sub'::character varying::text, 'Alternative'::character varying::text, 'Translated'::character varying::text, 'Other'::character varying::text]))
// )
// ALTER TABLE IF EXISTS dataset_titles
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE dataset_titles FROM tethys_app;
// GRANT ALL ON TABLE dataset_titles TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE dataset_titles TO tethys_app;

View file

@ -0,0 +1,48 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { TitleTypes } from 'Contracts/enums';
export default class DatasetTitles extends BaseSchema {
protected tableName = 'dataset_titles';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('dataset_titles_id_seq')");
table.integer('document_id').unsigned().notNullable();
table
.foreign('document_id', 'dataset_titles_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this titke when document is deleted
.onUpdate('CASCADE');
// table.string('type', 255).notNullable();
table.enum('type', Object.values(TitleTypes)).notNullable();
table.string('value', 255).notNullable();
table.string('language', 3).notNullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: dataset_titles
// CREATE TABLE IF NOT EXISTS dataset_titles
// (
// id integer NOT NULL DEFAULT nextval('dataset_titles_id_seq'::regclass),
// document_id integer NOT NULL,
// type character varying(255) NOT NULL,
// value character varying(255) NOT NULL,
// language character varying(3) NOT NULL,
// CONSTRAINT dataset_titles_pkey PRIMARY KEY (id),
// CONSTRAINT dataset_titles_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT dataset_titles_type_check CHECK (type::text = ANY (ARRAY['Main'::character varying::text, 'Sub'::character varying::text, 'Alternative'::character varying::text, 'Translated'::character varying::text, 'Other'::character varying::text]))
// )
// ALTER TABLE IF EXISTS dataset_titles
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE dataset_titles FROM tethys_app;
// GRANT ALL ON TABLE dataset_titles TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE dataset_titles TO tethys_app;

View file

@ -0,0 +1,40 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class CollectionsRoles extends BaseSchema {
protected tableName = 'collections_roles';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('collections_roles_id_seq')");
table.string('name', 255).notNullable();
table.string('oai_name', 255).notNullable();
table.integer('position').notNullable();
table.boolean('visible').notNullable().defaultTo(true);
table.boolean('visible_frontdoor').notNullable().defaultTo(true);
table.boolean('visible_oai').notNullable().defaultTo(true);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: collection roles
// CREATE TABLE IF NOT EXISTS collections_roles
// (
// id integer NOT NULL DEFAULT nextval('collections_roles_id_seq'::regclass),
// name character varying(255) NOT NULL,
// oai_name character varying(255) NOT NULL,
// "position" integer NOT NULL,
// visible boolean NOT NULL DEFAULT true,
// visible_frontdoor boolean NOT NULL DEFAULT true,
// visible_oai boolean NOT NULL DEFAULT true,
// CONSTRAINT collections_roles_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS collections_roles
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE collections_roles FROM tethys_app;
// GRANT ALL ON TABLE collections_roles TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE collections_roles TO tethys_app;

View file

@ -0,0 +1,61 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class Collections extends BaseSchema {
protected tableName = 'collections';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').defaultTo("nextval('collections_id_seq')");
table.integer('role_id').unsigned();
table
.foreign('role_id', 'collections_role_id_foreign')
.references('id')
.inTable('collections_roles')
.onDelete('CASCADE') // delete this collection when collection_role is deleted
.onUpdate('CASCADE');
table.string('number', 255);
table.string('name', 255).notNullable();
table.string('oai_subset', 255);
table.integer('parent_id').unsigned();
table
.foreign('parent_id', 'collections_parent_id_foreign')
.references('id')
.inTable('collections')
.onDelete('CASCADE') // delete this collection when parent collection is deleted
.onUpdate('CASCADE');
table.boolean('visible').notNullable().defaultTo(true);
table.boolean('visible_publish').notNullable().defaultTo(true);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: collections
// CREATE TABLE IF NOT EXISTS collections
// (
// id integer NOT NULL DEFAULT nextval('collections_id_seq'::regclass),
// role_id integer,
// "number" character varying(255),
// name character varying(255) NOT NULL,
// oai_subset character varying(255),
// parent_id integer,
// visible boolean NOT NULL DEFAULT true,
// visible_publish boolean NOT NULL DEFAULT true,
// CONSTRAINT collections_pkey PRIMARY KEY (id),
// CONSTRAINT collections_parent_id_foreign FOREIGN KEY (parent_id)
// REFERENCES collections (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT collections_role_id_foreign FOREIGN KEY (role_id)
// REFERENCES collections_roles (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS collections
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE collections FROM tethys_app;
// GRANT ALL ON TABLE collections TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE collections TO tethys_app;

View file

@ -0,0 +1,59 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class LinkDocumentsCollections extends BaseSchema {
protected tableName = 'link_documents_collections';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('collection_id').index('link_documents_collections_collection_id_index').notNullable();
table
.foreign('collection_id', 'link_documents_collections_collection_id_foreign')
.references('id')
.inTable('collections')
.onDelete('CASCADE') // don't delete this when collection is deleted
.onUpdate('CASCADE');
table.integer('document_id').index('link_documents_collections_document_id_index').notNullable();
table
.foreign('document_id', 'link_documents_collections_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // don't delete this when document is deleted
.onUpdate('CASCADE');
table.primary(['collection_id', 'document_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: link_documents_collections
// CREATE TABLE IF NOT EXISTS link_documents_collections
// (
// collection_id integer NOT NULL,
// document_id integer NOT NULL,
// CONSTRAINT link_documents_collections_pkey PRIMARY KEY (collection_id, document_id),
// CONSTRAINT link_documents_collections_collection_id_foreign FOREIGN KEY (collection_id)
// REFERENCES collections (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT link_documents_collections_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS link_documents_collections
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE link_documents_collections FROM tethys_app;
// GRANT ALL ON TABLE link_documents_collections TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE link_documents_collections TO tethys_app;
// -- Index: link_documents_collections_collection_id_index
// -- DROP INDEX IF EXISTS link_documents_collections_collection_id_index;
// CREATE INDEX IF NOT EXISTS link_documents_collections_collection_id_index
// ON link_documents_collections USING btree (collection_id ASC);
// -- Index: link_documents_collections_document_id_index
// -- DROP INDEX IF EXISTS link_documents_collections_document_id_index;
// CREATE INDEX IF NOT EXISTS link_documents_collections_document_id_index
// ON link_documents_collections USING btree (document_id ASC);

View file

@ -0,0 +1,56 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { PersonNameTypes } from 'Contracts/enums';
export default class Persons extends BaseSchema {
protected tableName = 'persons';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('persons_id_seq')");
table.string('academic_title', 255);
table.string('date_of_birth', 100);
table.string('email', 100).notNullable();
table.string('first_name', 255);
table.string('last_name', 255);
table.string('place_of_birth', 255);
table.string('identifier_orcid', 50);
table.string('identifier_gnd', 50);
table.string('identifier_misc', 50);
table.boolean('status').defaultTo(true);
table.integer('registered_at');
// table.string('name_type', 255);
table.enum('name_type', Object.values(PersonNameTypes)).notNullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: persons
// CREATE TABLE IF NOT EXISTS persons
// (
// id integer NOT NULL DEFAULT nextval('persons_id_seq'::regclass),
// academic_title character varying(255),
// date_of_birth character varying(100),
// email character varying(100) NOT NULL,
// first_name character varying(255),
// last_name character varying(255),
// place_of_birth character varying(255),
// identifier_orcid character varying(50),
// identifier_gnd character varying(50),
// identifier_misc character varying(50),
// status boolean DEFAULT true,
// registered_at integer,
// name_type character varying(255),
// CONSTRAINT persons_pkey PRIMARY KEY (id),
// CONSTRAINT persons_name_type_check CHECK (name_type::text = ANY (ARRAY['Organizational'::character varying::text, 'Personal'::character varying::text]))
// )
// ALTER TABLE IF EXISTS persons
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE persons FROM tethys_app;
// GRANT ALL ON TABLE persons TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE persons TO tethys_app;

View file

@ -0,0 +1,61 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class DocumentFiles extends BaseSchema {
protected tableName = 'document_files';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('document_files_id_seq')");
table.integer('document_id').unsigned().notNullable();
table
.foreign('document_id', 'document_files_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this when document is deleted
.onUpdate('CASCADE');
table.string('path_name').notNullable();
table.string('label');
table.string('comment');
table.string('mime_type');
table.string('language');
table.bigInteger('file_size').notNullable();
table.boolean('visible_in_frontdoor').notNullable().defaultTo(true);
table.boolean('visible_in_oai').notNullable().defaultTo(true);
table.integer('sort_order').notNullable();
table.timestamp('created_at');
table.timestamp('updated_at');
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: document_files
// CREATE TABLE IF NOT EXISTS document_files
// (
// id integer NOT NULL DEFAULT nextval('document_files_id_seq'::regclass),
// document_id integer NOT NULL,
// path_name character varying(100) NOT NULL,
// label character varying(100),
// comment character varying(255),
// mime_type character varying(255),
// language character varying(3),
// file_size bigint NOT NULL,
// visible_in_frontdoor boolean NOT NULL DEFAULT true,
// visible_in_oai boolean NOT NULL DEFAULT true,
// sort_order integer NOT NULL,
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT document_files_pkey PRIMARY KEY (id),
// CONSTRAINT document_files_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS document_files
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE document_files FROM tethys_app;
// GRANT ALL ON TABLE document_files TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE document_files TO tethys_app;

View file

@ -0,0 +1,42 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class FileHashvalues extends BaseSchema {
protected tableName = 'file_hashvalues';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('file_id').notNullable();
table
.foreign('file_id', 'file_hashvalues_file_id_foreign')
.references('id')
.inTable('document_files')
.onDelete('CASCADE') // delete this when document_file is deleted
.onUpdate('CASCADE');
table.string('type', 50).notNullable();
table.string('value').notNullable();
table.primary(['file_id', 'type']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: file_hashvalues
// CREATE TABLE IF NOT EXISTS file_hashvalues
// (
// file_id integer NOT NULL,
// type character varying(50) NOT NULL,
// value character varying(255) NOT NULL,
// CONSTRAINT file_hashvalues_pkey PRIMARY KEY (file_id, type),
// CONSTRAINT file_hashvalues_file_id_foreign FOREIGN KEY (file_id)
// REFERENCES document_files (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE
// )
// ALTER TABLE IF EXISTS file_hashvalues
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE file_hashvalues FROM tethys_app;
// GRANT ALL ON TABLE file_hashvalues TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE file_hashvalues TO tethys_app;

View file

@ -0,0 +1,53 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class DocumentLicences extends BaseSchema {
protected tableName = 'document_licences';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('document_licences_id_seq')");
table.boolean('active').notNullable().defaultTo(true);
table.string('comment_internal', 4000);
table.string('desc_markup', 4000);
table.string('desc_text', 4000);
table.string('language', 3);
table.string('link_licence', 200).notNullable();
table.string('link_logo', 200);
table.string('link_sign', 200);
table.string('mime_type', 30);
table.string('name_long', 200).notNullable();
table.string('name', 50).notNullable();
table.boolean('pod_allowed').notNullable().defaultTo(false);
table.specificType('sort_order', 'smallint').notNullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: document_licences
// CREATE TABLE IF NOT EXISTS document_licences
// (
// id integer NOT NULL DEFAULT nextval('document_licences_id_seq'::regclass),
// active boolean NOT NULL DEFAULT true,
// comment_internal character varying(4000),
// desc_markup character varying(4000),
// desc_text character varying(4000),
// language character varying(3),
// link_licence character varying(200) NOT NULL,
// link_logo character varying(200),
// link_sign character varying(200),
// mime_type character varying(30),
// name_long character varying(200) NOT NULL,
// name character varying(50) NOT NULL,
// pod_allowed boolean NOT NULL DEFAULT false,
// sort_order smallint NOT NULL,
// CONSTRAINT document_licences_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS document_licences
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE document_licences FROM tethys_app;
// GRANT ALL ON TABLE document_licences TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE document_licences TO tethys_app;

View file

@ -0,0 +1,63 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
import { PersonRoles } from 'Contracts/enums';
export default class LinkDocumentsLicences extends BaseSchema {
protected tableName = 'link_documents_licences';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.integer('licence_id').index('link_documents_licences_licence_id_index').notNullable();
table
.foreign('licence_id', 'link_documents_licences_licence_id_foreign')
.references('id')
.inTable('document_licences')
.onDelete('NO ACTION') // don't delete this when license is deleted
.onUpdate('NO ACTION');
// table.index('licence_id', 'link_documents_licences_licence_id_index')
table.integer('document_id').index('link_documents_licences_document_id_index').notNullable();
table
.foreign('document_id', 'link_documents_licences_document_id_foreign')
.references('id')
.inTable('documents')
.onDelete('CASCADE') // delete this when permission is deleted
.onUpdate(' CASCADE');
// table.index('licence_id', 'link_documents_licences_document_id_index')
table.primary(['licence_id', 'document_id']);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: link_documents_licences
// CREATE TABLE IF NOT EXISTS link_documents_licences
// (
// licence_id integer NOT NULL,
// document_id integer NOT NULL,
// role character varying(255) NOT NULL DEFAULT 'other'::character varying,
// CONSTRAINT link_documents_licences_pkey PRIMARY KEY (licence_id, document_id),
// CONSTRAINT link_documents_licences_document_id_foreign FOREIGN KEY (document_id)
// REFERENCES documents (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT link_documents_licences_licence_id_foreign FOREIGN KEY (licence_id)
// REFERENCES document_licences (id) MATCH SIMPLE
// ON UPDATE NO ACTION
// ON DELETE NO ACTION,
// )
// ALTER TABLE IF EXISTS link_documents_licences
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE link_documents_licences FROM tethys_app;
// GRANT ALL ON TABLE link_documents_licences TO tethys_admin;
// GRANT DELETE, INSERT, SELECT, UPDATE ON TABLE link_documents_licences TO tethys_app;
// -- Index: link_documents_licences_document_id_index
// CREATE INDEX IF NOT EXISTS link_documents_licences_document_id_index
// ON link_documents_licences USING btree
// (document_id ASC);
// -- Index: link_documents_licences_licence_id_index
// CREATE INDEX IF NOT EXISTS link_documents_licences_licence_id_index
// ON link_documents_licences USING btree
// (licence_id ASC);

View file

@ -0,0 +1,37 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class MimeTypes extends BaseSchema {
protected tableName = 'mime_types';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('mime_types_id_seq')");
table.string('name', 255).notNullable();
table.string('file_extension', 255).notNullable();
table.boolean('enabled').notNullable().defaultTo(false);
table.timestamp('created_at', { useTz: false }).nullable();
table.timestamp('updated_at', { useTz: false }).nullable();
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: mime_types
// CREATE TABLE IF NOT EXISTS mime_types
// (
// id integer NOT NULL DEFAULT nextval('mime_types_id_seq'::regclass),
// name character varying(255) NOT NULL,
// file_extension character varying(255) NOT NULL,
// enabled boolean NOT NULL DEFAULT false,
// created_at timestamp(0) without time zone,
// updated_at timestamp(0) without time zone,
// CONSTRAINT mime_types_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS mime_types
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE mime_types FROM tethys_app;
// GRANT ALL ON TABLE mime_types TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE mime_types TO tethys_app;

View file

@ -0,0 +1,41 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class Languages extends BaseSchema {
protected tableName = 'languages';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').primary().defaultTo("nextval('languages_id_seq')");
table.string('part2_b', 3).notNullable();
table.string('part2_t', 3).notNullable();
table.string('part1', 2).notNullable();
table.string('scope', 20).notNullable();
table.string('type', 20).notNullable();
table.string('ref_name', 150).notNullable();
table.boolean('active').notNullable().defaultTo(true);
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: languages
// CREATE TABLE IF NOT EXISTS languages
// (
// id integer NOT NULL DEFAULT nextval('languages_id_seq'::regclass),
// part2_b character varying(3) NOT NULL,
// part2_t character varying(3) NOT NULL,
// part1 character varying(2) NOT NULL,
// scope character varying(20) NOT NULL,
// type character varying(20) NOT NULL,
// ref_name character varying(150) NOT NULL,
// active boolean NOT NULL DEFAULT true,
// CONSTRAINT languages_pkey PRIMARY KEY (id)
// )
// ALTER TABLE IF EXISTS languages
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE languages FROM tethys_app;
// GRANT ALL ON TABLE languages TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE languages TO tethys_app;

View file

@ -0,0 +1,33 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
export default class DocumentXmlCache extends BaseSchema {
protected tableName = 'document_xml_cache';
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('document_id').primary();
table.integer('xml_version').notNullable();
table.string('server_date_modified', 50);
table.text('xml_data');
});
}
public async down() {
this.schema.dropTable(this.tableName);
}
}
// -- Table: document_xml_cache
// CREATE TABLE IF NOT EXISTS document_xml_cache
// (
// document_id integer NOT NULL,
// xml_version integer NOT NULL,
// server_date_modified character varying(50),
// xml_data text,
// CONSTRAINT document_xml_cache_pkey PRIMARY KEY (document_id)
// )
// ALTER TABLE IF EXISTS document_xml_cache
// OWNER to tethys_admin;
// REVOKE ALL ON TABLE document_xml_cache FROM tethys_app;
// GRANT ALL ON TABLE document_xml_cache TO tethys_admin;
// GRANT DELETE, UPDATE, INSERT, SELECT ON TABLE document_xml_cache TO tethys_app;

View file

@ -0,0 +1,32 @@
docker exec -it tethys_db /bin/bash
su -l postgres
psql
drop database test with (force);
create database test;
\q
psql -d test -U postgres -p 5432
CREATE SCHEMA IF NOT EXISTS gba AUTHORIZATION tethys_admin;
CREATE EXTENSION adminpack;
\q
exit
exit
node ace migration:run
migrated database/migrations/acl_1_roles
migrated database/migrations/acl_2_permissions
migrated database/migrations/acl_3_role_has_permissions
migrated database/migrations/acl_4_accounts
migrated database/migrations/acl_5_link_accounts_roles
migrated database/migrations/files_1681720090636_documents
migrated database/migrations/files_1681720091636_document_files
migrated database/migrations/files_1681720092636_file_hashvalues
node ace migration:rollback