tethys.backend/database/migrations/dataset_7_collections.ts
Arno Kaimbacher b540547e4c
All checks were successful
CI / container-job (push) Successful in 49s
feat: update API controllers, validations, and Vue components
- Modified Api/Authors.Controller.ts to use only personal types and sort by dataset_count.
- Completely rewritten AvatarController.ts.
- Added new Api/CollectionsController.ts for querying collections and collection_roles.
- Modified Api/DatasetController.ts to preload titles, identifier and order by server_date_published.
- Modified FileController.ts to serve files from /storage/app/data/ instead of /storage/app/public.
- Added new Api/UserController for requesting submitters (getSubmitters).
- Improved OaiController.ts with performant DB queries for better ResumptionToken handling.
- Modified Submitter/DatasetController.ts by adding a categorize method for library classification.
- Rewritten ResumptionToken.ts.
- Improved TokenWorkerService.ts to utilize browser fingerprint.
- Edited dataset.ts by adding the doiIdentifier property.
- Enhanced person.ts to improve the fullName property.
- Completely rewritten AsideMenuItem.vue component.
- Updated CarBoxClient.vue to use TypeScript.
- Added new CardBoxDataset.vue for displaying recent datasets on the dashboard.
- Completely rewritten TableSampleClients.vue for the dashboard.
- Completely rewritten UserAvatar.vue.
- Made small layout changes in Dashboard.vue.
- Added new Category.vue for browsing scientific collections.
- Adapted the pinia store in main.ts.
- Added additional routes in start/routes.ts and start/api/routes.ts.
- Improved referenceValidation.ts for better ISBN existence checking.
- NPM dependency updates.
2025-03-14 17:39:58 +01:00

61 lines
2.3 KiB
TypeScript

import { BaseSchema } from "@adonisjs/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
// )
// change to normal intzeger:
// ALTER TABLE collections ALTER COLUMN id DROP DEFAULT;
// DROP SEQUENCE IF EXISTS collections_id_seq;