mcp key
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddMcpApiKeyToUsers1781600000000 implements MigrationInterface {
|
||||
name = 'AddMcpApiKeyToUsers1781600000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
if (!(await queryRunner.hasTable('users'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await queryRunner.hasColumn('users', 'mcpApiKeyHash'))) {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE `users` ADD `mcpApiKeyHash` varchar(64) NULL',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'CREATE UNIQUE INDEX `IDX_users_mcp_api_key_hash` ON `users` (`mcpApiKeyHash`)',
|
||||
);
|
||||
}
|
||||
|
||||
if (!(await queryRunner.hasColumn('users', 'mcpApiKeyCreatedAt'))) {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE `users` ADD `mcpApiKeyCreatedAt` datetime(3) NULL',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
if (!(await queryRunner.hasTable('users'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await queryRunner.hasColumn('users', 'mcpApiKeyHash')) {
|
||||
await queryRunner.query(
|
||||
'DROP INDEX `IDX_users_mcp_api_key_hash` ON `users`',
|
||||
);
|
||||
await queryRunner.query('ALTER TABLE `users` DROP COLUMN `mcpApiKeyHash`');
|
||||
}
|
||||
|
||||
if (await queryRunner.hasColumn('users', 'mcpApiKeyCreatedAt')) {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE `users` DROP COLUMN `mcpApiKeyCreatedAt`',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user