feat: add initial migration for token, project, module, query, and plugin tables
This commit is contained in:
@ -1,15 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class ApiTokensInit1758026710027 implements MigrationInterface {
|
|
||||||
name = "ApiTokensInit1758026710027";
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE \`token\` (\`id\` varchar(36) NOT NULL, \`isActive\` tinyint NOT NULL DEFAULT '0', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE \`token\``);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class Query1758118369785 implements MigrationInterface {
|
|
||||||
name = "Query1758118369785";
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE \`project\` (\`token\` varchar(36) NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`token\`)) ENGINE=InnoDB`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE \`module\` (\`id\` varchar(36) NOT NULL, \`sourcePath\` varchar(255) NOT NULL, \`name\` varchar(255) NOT NULL, \`isInjectable\` tinyint NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE \`query\` (\`id\` varchar(36) NOT NULL, \`source\` longtext NOT NULL, \`isActive\` tinyint NOT NULL DEFAULT '1', \`projectToken\` varchar(36) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`token\` DROP PRIMARY KEY`);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`token\` DROP COLUMN \`id\``);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` ADD \`token\` varchar(36) NOT NULL PRIMARY KEY`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` ADD \`projectToken\` varchar(36) NULL`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` ADD CONSTRAINT \`FK_f0bc174c878df5e005c38fe05bd\` FOREIGN KEY (\`projectToken\`) REFERENCES \`project\`(\`token\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`query\` ADD CONSTRAINT \`FK_f58429a7d32fbb51ead8c4daf0a\` FOREIGN KEY (\`projectToken\`) REFERENCES \`project\`(\`token\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`query\` DROP FOREIGN KEY \`FK_f58429a7d32fbb51ead8c4daf0a\``
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` DROP FOREIGN KEY \`FK_f0bc174c878df5e005c38fe05bd\``
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` DROP COLUMN \`projectToken\``
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`token\` DROP COLUMN \`token\``);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE \`token\` ADD \`id\` varchar(36) NOT NULL`
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE \`token\` ADD PRIMARY KEY (\`id\`)`);
|
|
||||||
await queryRunner.query(`DROP TABLE \`query\``);
|
|
||||||
await queryRunner.query(`DROP TABLE \`module\``);
|
|
||||||
await queryRunner.query(`DROP TABLE \`project\``);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class ModulesAndPluigns1758401762034 implements MigrationInterface {
|
|
||||||
name = 'ModulesAndPluigns1758401762034'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`CREATE TABLE \`plugin\` (\`id\` varchar(36) NOT NULL, \`class\` varchar(255) NOT NULL, \`name\` varchar(255) NOT NULL, \`config\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE \`plugin\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
43
src/migrations/1758534887223-init.ts
Normal file
43
src/migrations/1758534887223-init.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class Init1758534887223 implements MigrationInterface {
|
||||||
|
name = "Init1758534887223";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE \`token\` (\`token\` uuid NOT NULL, \`isActive\` tinyint NOT NULL DEFAULT '0', \`projectToken\` uuid NULL, PRIMARY KEY (\`token\`)) ENGINE=InnoDB`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE \`project\` (\`token\` uuid NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`token\`)) ENGINE=InnoDB`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE \`module\` (\`id\` uuid NOT NULL, \`sourcePath\` varchar(255) NOT NULL, \`name\` varchar(255) NOT NULL, \`isInjectable\` tinyint NOT NULL DEFAULT '1', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE \`query\` (\`id\` uuid NOT NULL, \`source\` longtext NOT NULL, \`isActive\` tinyint NOT NULL DEFAULT '1', \`projectToken\` uuid NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE \`plugin\` (\`id\` uuid NOT NULL, \`class\` varchar(255) NOT NULL, \`name\` varchar(255) NOT NULL, \`config\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`token\` ADD CONSTRAINT \`FK_f0bc174c878df5e005c38fe05bd\` FOREIGN KEY (\`projectToken\`) REFERENCES \`project\`(\`token\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`query\` ADD CONSTRAINT \`FK_f58429a7d32fbb51ead8c4daf0a\` FOREIGN KEY (\`projectToken\`) REFERENCES \`project\`(\`token\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`query\` DROP FOREIGN KEY \`FK_f58429a7d32fbb51ead8c4daf0a\``
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`token\` DROP FOREIGN KEY \`FK_f0bc174c878df5e005c38fe05bd\``
|
||||||
|
);
|
||||||
|
await queryRunner.query(`DROP TABLE \`plugin\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`query\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`module\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`project\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`token\``);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user