mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
24 lines
765 B
TypeScript
24 lines
765 B
TypeScript
import type { MigrationContext, ReversibleMigration } from '@db/types';
|
|
|
|
export class AddAPIKeyColumn1652905585850 implements ReversibleMigration {
|
|
async up({ queryRunner, tablePrefix }: MigrationContext) {
|
|
await queryRunner.query(
|
|
'ALTER TABLE `' + tablePrefix + 'user` ADD COLUMN `apiKey` VARCHAR(255)',
|
|
);
|
|
await queryRunner.query(
|
|
'CREATE UNIQUE INDEX `UQ_' +
|
|
tablePrefix +
|
|
'ie0zomxves9w3p774drfrkxtj5` ON `' +
|
|
tablePrefix +
|
|
'user` (`apiKey`)',
|
|
);
|
|
}
|
|
|
|
async down({ queryRunner, tablePrefix }: MigrationContext) {
|
|
await queryRunner.query(
|
|
`DROP INDEX \`UQ_${tablePrefix}ie0zomxves9w3p774drfrkxtj5\` ON \`${tablePrefix}user\``,
|
|
);
|
|
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'user` DROP COLUMN `apiKey`');
|
|
}
|
|
}
|