tethys.backend/database/migrations/config_2_backupcodes_table.ts
Arno Kaimbacher 2c4f51be68
Some checks failed
CI Pipeline / japa-tests (push) Failing after 51s
feat: Enhance reference validation and add support for Handle URLs
- Updated reference validation to handle various identifier types including DOI, ISBN, ISSN, URN, and Handle.
- Improved regex patterns for DOI and Handle validation to correctly extract and validate identifiers from URLs.
- Added asynchronous checks to verify the existence of DOI and Handle URLs.
- Added asynchronous checks to verify the existence of  ISBNs
- Included detailed comments explaining the regex patterns and validation logic.
- Adjusted the validation logic to handle any URL prefix for Handle identifiers.
- Ensured that the Handle format `handle/20.500.12854/36478` is correctly validated.
- Updated the CI workflow to trigger on push and pull request events.
2025-01-24 17:11:10 +01:00

55 lines
1.6 KiB
TypeScript

// node ace make:migration backupcodes
import { BaseSchema } from '@adonisjs/lucid/schema';
export default class extends BaseSchema {
protected tableName = 'backupcodes';
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id');
table.integer('user_id').unsigned();
table.string('code', 64).notNullable();
table.boolean('used').defaultTo(false);
table.foreign('user_id').references('id').inTable('accounts').onUpdate('CASCADE').onDelete('CASCADE');
table.index('user_id', 'backupcodes_uid');
});
}
async down() {
this.schema.dropTable(this.tableName);
}
}
// CREATE SEQUENCE IF NOT EXISTS gba.backupcodes_id_seq
// INCREMENT 1
// START 1
// MINVALUE 1
// MAXVALUE 2147483647
// CACHE 1;
// ALTER SEQUENCE gba.backupcodes_id_seq
// OWNER TO tethys_admin;
// GRANT ALL ON SEQUENCE gba.backupcodes_id_seq TO tethys_admin;
// GRANT USAGE ON SEQUENCE gba.backupcodes_id_seq TO tethys_app;
// CREATE TABLE IF NOT EXISTS gba.backupcodes
// (
// id integer NOT NULL DEFAULT nextval('gba.backupcodes_id_seq'::regclass),
// user_id integer,
// code character varying(64) NOT NULL,
// used boolean NOT NULL DEFAULT false,
// CONSTRAINT backupcodes_user_id_foreign FOREIGN KEY (user_id)
// REFERENCES gba.accounts (id) MATCH SIMPLE
// ON UPDATE CASCADE
// ON DELETE CASCADE,
// CONSTRAINT backupcodes_pkey PRIMARY KEY (id)
// )
// CREATE INDEX IF NOT EXISTS backupcodes_uid
// ON gba.backupcodes USING btree
// (user_id ASC);