forked from geolba/tethys.backend
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
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;
|