tethys.backend/database/migrations/dataset_6_collection_roles.ts
Arno Kaimbacher 0bf442be96 hotfix(dataset): improve dataset classification UI and data handling
- Updated the Dataset and Submitter Category Vue components to enhance the UI for library classification. The collection names and numbers are now displayed with distinct styling using `span` elements with specific classes for better readability.
- Modified the DatasetController and Editor/DatasetController to filter collection roles by 'ddc' and 'ccs' names when preloading collections, improving data retrieval efficiency.
- Added `left_id` and `right_id` columns to the `collections` table in the `dataset_7_collections.ts` migration file.
- Added a migration to reorder the collection_roles table.
2025-05-06 17:43:37 +02:00

52 lines
No EOL
2 KiB
TypeScript

import { BaseSchema } from "@adonisjs/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)
// )
// change to normal intzeger:
// ALTER TABLE collections_roles ALTER COLUMN id DROP DEFAULT;
// DROP SEQUENCE IF EXISTS collections_roles_id_seq;
// -- Step 1: Temporarily change one ID to a value not currently used
// UPDATE collections_roles SET id = 99 WHERE name = 'ccs';
// -- Step 2: Change 'ddc' ID to 2 (the old 'ccs' ID)
// UPDATE collections_roles SET id = 2 WHERE name = 'ddc';
// -- Step 3: Change the temporary ID (99) to 3 (the old 'ddc' ID)
// UPDATE collections_roles SET id = 3 WHERE name = 'ccs';
// UPDATE collections_roles SET id = 99 WHERE name = 'bk';
// UPDATE collections_roles SET id = 1 WHERE name = 'institutes';
// UPDATE collections_roles SET id = 4 WHERE name = 'pacs';
// UPDATE collections_roles SET id = 7 WHERE name = 'bk';