|
|
|
@@ -0,0 +1,277 @@
|
|
|
|
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initial schema. Databases created before migrations existed (by TypeORM
|
|
|
|
|
* `synchronize`) already have this schema: for them this migration only gets
|
|
|
|
|
* recorded as applied, and later migrations run from there.
|
|
|
|
|
*/
|
|
|
|
|
export class Initial1790793447827 implements MigrationInterface {
|
|
|
|
|
name = "Initial1790793447827";
|
|
|
|
|
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
|
if (await queryRunner.hasTable("scenarios")) return;
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "credentials" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "data" text, "lastUsedAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "environments" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "data" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_9d00da4836959b86d7590f60c57" UNIQUE ("name"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "files" ("id" varchar PRIMARY KEY NOT NULL, "originalName" varchar NOT NULL, "mimeType" varchar NOT NULL, "size" integer NOT NULL, "sha256" varchar NOT NULL, "filePath" varchar NOT NULL, "expiresAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_credentials" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "credentialId" varchar NOT NULL, "alias" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_02756536236c408dbb58b3fc964" UNIQUE ("scenarioId", "alias"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_steps" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "order" integer NOT NULL DEFAULT (0), "title" text, "execCode" text, "timeoutSeconds" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenarios" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" varchar, "timeoutSeconds" integer, "version" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_files" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "sessions" ("id" varchar PRIMARY KEY NOT NULL, "sessionName" varchar NOT NULL, "token" text NOT NULL, "cookies" text NOT NULL, "localStorage" text NOT NULL DEFAULT ('{}'), "status" varchar NOT NULL DEFAULT ('closed'), "lastUsedAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_b8f17f1ce30f015f494188c50bb" UNIQUE ("sessionName"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_steps" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "scenarioStepId" varchar, "title" text, "execCode" text, "timeoutSeconds" integer, "status" text NOT NULL DEFAULT ('waiting'), "order" integer NOT NULL DEFAULT (0), "description" text, "output" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_runs" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "environmentId" varchar, "sessionId" varchar, "scenarioVersion" integer, "status" text NOT NULL DEFAULT ('pending'), "saveSession" boolean NOT NULL DEFAULT (0), "traceMode" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_files" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_logs" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "stepRunId" varchar, "level" text NOT NULL DEFAULT ('log'), "message" text NOT NULL, "seq" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_versions" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "version" integer NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" text, "timeoutSeconds" integer, "steps" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_e1a56dce2b7e0379bb5bbdf8c1f" UNIQUE ("scenarioId", "version"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "snippets" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar, "title" varchar NOT NULL DEFAULT (''), "description" text, "code" text NOT NULL, "version" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_bd062c68591ae917b720eb3427c" UNIQUE ("alias"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "snippet_versions" ("id" varchar PRIMARY KEY NOT NULL, "snippetId" varchar NOT NULL, "version" integer NOT NULL, "alias" varchar NOT NULL, "title" varchar NOT NULL DEFAULT (''), "description" text, "code" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_2487f4aabeb20c4192ee30e09a2" UNIQUE ("snippetId", "version"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_credentials" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "credentialId" varchar NOT NULL, "alias" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_02756536236c408dbb58b3fc964" UNIQUE ("scenarioId", "alias"), CONSTRAINT "FK_37f19dadd8e524b22a807ece1a9" FOREIGN KEY ("scenarioId") REFERENCES "scenarios" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_96676b988693d5ca2923782530c" FOREIGN KEY ("credentialId") REFERENCES "credentials" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_credentials"("id", "scenarioId", "credentialId", "alias", "createdAt") SELECT "id", "scenarioId", "credentialId", "alias", "createdAt" FROM "scenario_credentials"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_credentials"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_credentials" RENAME TO "scenario_credentials"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_steps" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "order" integer NOT NULL DEFAULT (0), "title" text, "execCode" text, "timeoutSeconds" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_4bab3637cc3bf37677bb01c7446" FOREIGN KEY ("scenarioId") REFERENCES "scenarios" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_steps"("id", "scenarioId", "order", "title", "execCode", "timeoutSeconds", "createdAt", "updatedAt") SELECT "id", "scenarioId", "order", "title", "execCode", "timeoutSeconds", "createdAt", "updatedAt" FROM "scenario_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_steps"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_steps" RENAME TO "scenario_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenarios" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" varchar, "timeoutSeconds" integer, "version" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_ffdcf9186d95114f0dab068e20a" FOREIGN KEY ("environmentId") REFERENCES "environments" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenarios"("id", "name", "description", "environmentId", "timeoutSeconds", "version", "createdAt", "updatedAt") SELECT "id", "name", "description", "environmentId", "timeoutSeconds", "version", "createdAt", "updatedAt" FROM "scenarios"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenarios"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenarios" RENAME TO "scenarios"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_files" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_c41719984235f8984d1c6b92ef5" FOREIGN KEY ("scenarioId") REFERENCES "scenarios" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_67013a49e7948fb530a7d956e2b" FOREIGN KEY ("fileId") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_files"("id", "scenarioId", "fileId", "createdAt") SELECT "id", "scenarioId", "fileId", "createdAt" FROM "scenario_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_files"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_files" RENAME TO "scenario_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_run_steps" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "scenarioStepId" varchar, "title" text, "execCode" text, "timeoutSeconds" integer, "status" text NOT NULL DEFAULT ('waiting'), "order" integer NOT NULL DEFAULT (0), "description" text, "output" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_213c27405af3433011121babb58" FOREIGN KEY ("runId") REFERENCES "scenario_runs" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_e84cd4c7725bdc5dfd09d18d92f" FOREIGN KEY ("scenarioStepId") REFERENCES "scenario_steps" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_run_steps"("id", "runId", "scenarioStepId", "title", "execCode", "timeoutSeconds", "status", "order", "description", "output", "createdAt", "updatedAt") SELECT "id", "runId", "scenarioStepId", "title", "execCode", "timeoutSeconds", "status", "order", "description", "output", "createdAt", "updatedAt" FROM "scenario_run_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_steps"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_run_steps" RENAME TO "scenario_run_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_runs" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "environmentId" varchar, "sessionId" varchar, "scenarioVersion" integer, "status" text NOT NULL DEFAULT ('pending'), "saveSession" boolean NOT NULL DEFAULT (0), "traceMode" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_1d2c2595dfff133de062f9c692a" FOREIGN KEY ("scenarioId") REFERENCES "scenarios" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_5076ffbd1b4fa71f5de011eba1f" FOREIGN KEY ("environmentId") REFERENCES "environments" ("id") ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT "FK_068b01cdfa49095433f245d6708" FOREIGN KEY ("sessionId") REFERENCES "sessions" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_runs"("id", "scenarioId", "environmentId", "sessionId", "scenarioVersion", "status", "saveSession", "traceMode", "createdAt", "updatedAt") SELECT "id", "scenarioId", "environmentId", "sessionId", "scenarioVersion", "status", "saveSession", "traceMode", "createdAt", "updatedAt" FROM "scenario_runs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_runs"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_runs" RENAME TO "scenario_runs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_run_files" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_5fc35a4bfc42d7566a0f7706902" FOREIGN KEY ("runId") REFERENCES "scenario_runs" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_637619025bdb0b6a89fae6e178d" FOREIGN KEY ("fileId") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_run_files"("id", "runId", "fileId", "createdAt") SELECT "id", "runId", "fileId", "createdAt" FROM "scenario_run_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_files"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_run_files" RENAME TO "scenario_run_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_run_logs" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "stepRunId" varchar, "level" text NOT NULL DEFAULT ('log'), "message" text NOT NULL, "seq" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_dde48478a42823e583a360dd468" FOREIGN KEY ("runId") REFERENCES "scenario_runs" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_62d82b9fce3a6a2947ed1136c67" FOREIGN KEY ("stepRunId") REFERENCES "scenario_run_steps" ("id") ON DELETE SET NULL ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_run_logs"("id", "runId", "stepRunId", "level", "message", "seq", "createdAt") SELECT "id", "runId", "stepRunId", "level", "message", "seq", "createdAt" FROM "scenario_run_logs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_logs"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_run_logs" RENAME TO "scenario_run_logs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_scenario_versions" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "version" integer NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" text, "timeoutSeconds" integer, "steps" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_e1a56dce2b7e0379bb5bbdf8c1f" UNIQUE ("scenarioId", "version"), CONSTRAINT "FK_f5ccfb45c7847cfab74cf4f17b6" FOREIGN KEY ("scenarioId") REFERENCES "scenarios" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_scenario_versions"("id", "scenarioId", "version", "name", "description", "environmentId", "timeoutSeconds", "steps", "createdAt") SELECT "id", "scenarioId", "version", "name", "description", "environmentId", "timeoutSeconds", "steps", "createdAt" FROM "scenario_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_versions"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_scenario_versions" RENAME TO "scenario_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "temporary_snippet_versions" ("id" varchar PRIMARY KEY NOT NULL, "snippetId" varchar NOT NULL, "version" integer NOT NULL, "alias" varchar NOT NULL, "title" varchar NOT NULL DEFAULT (''), "description" text, "code" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_2487f4aabeb20c4192ee30e09a2" UNIQUE ("snippetId", "version"), CONSTRAINT "FK_0d3a004957c9553619be11635fd" FOREIGN KEY ("snippetId") REFERENCES "snippets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "temporary_snippet_versions"("id", "snippetId", "version", "alias", "title", "description", "code", "createdAt") SELECT "id", "snippetId", "version", "alias", "title", "description", "code", "createdAt" FROM "snippet_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "snippet_versions"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "temporary_snippet_versions" RENAME TO "snippet_versions"`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "snippet_versions" RENAME TO "temporary_snippet_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "snippet_versions" ("id" varchar PRIMARY KEY NOT NULL, "snippetId" varchar NOT NULL, "version" integer NOT NULL, "alias" varchar NOT NULL, "title" varchar NOT NULL DEFAULT (''), "description" text, "code" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_2487f4aabeb20c4192ee30e09a2" UNIQUE ("snippetId", "version"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "snippet_versions"("id", "snippetId", "version", "alias", "title", "description", "code", "createdAt") SELECT "id", "snippetId", "version", "alias", "title", "description", "code", "createdAt" FROM "temporary_snippet_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_snippet_versions"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_versions" RENAME TO "temporary_scenario_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_versions" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "version" integer NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" text, "timeoutSeconds" integer, "steps" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_e1a56dce2b7e0379bb5bbdf8c1f" UNIQUE ("scenarioId", "version"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_versions"("id", "scenarioId", "version", "name", "description", "environmentId", "timeoutSeconds", "steps", "createdAt") SELECT "id", "scenarioId", "version", "name", "description", "environmentId", "timeoutSeconds", "steps", "createdAt" FROM "temporary_scenario_versions"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_versions"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_run_logs" RENAME TO "temporary_scenario_run_logs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_logs" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "stepRunId" varchar, "level" text NOT NULL DEFAULT ('log'), "message" text NOT NULL, "seq" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_run_logs"("id", "runId", "stepRunId", "level", "message", "seq", "createdAt") SELECT "id", "runId", "stepRunId", "level", "message", "seq", "createdAt" FROM "temporary_scenario_run_logs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_run_logs"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_run_files" RENAME TO "temporary_scenario_run_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_files" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_run_files"("id", "runId", "fileId", "createdAt") SELECT "id", "runId", "fileId", "createdAt" FROM "temporary_scenario_run_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_run_files"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_runs" RENAME TO "temporary_scenario_runs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_runs" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "environmentId" varchar, "sessionId" varchar, "scenarioVersion" integer, "status" text NOT NULL DEFAULT ('pending'), "saveSession" boolean NOT NULL DEFAULT (0), "traceMode" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_runs"("id", "scenarioId", "environmentId", "sessionId", "scenarioVersion", "status", "saveSession", "traceMode", "createdAt", "updatedAt") SELECT "id", "scenarioId", "environmentId", "sessionId", "scenarioVersion", "status", "saveSession", "traceMode", "createdAt", "updatedAt" FROM "temporary_scenario_runs"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_runs"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_run_steps" RENAME TO "temporary_scenario_run_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_run_steps" ("id" varchar PRIMARY KEY NOT NULL, "runId" varchar NOT NULL, "scenarioStepId" varchar, "title" text, "execCode" text, "timeoutSeconds" integer, "status" text NOT NULL DEFAULT ('waiting'), "order" integer NOT NULL DEFAULT (0), "description" text, "output" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_run_steps"("id", "runId", "scenarioStepId", "title", "execCode", "timeoutSeconds", "status", "order", "description", "output", "createdAt", "updatedAt") SELECT "id", "runId", "scenarioStepId", "title", "execCode", "timeoutSeconds", "status", "order", "description", "output", "createdAt", "updatedAt" FROM "temporary_scenario_run_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_run_steps"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_files" RENAME TO "temporary_scenario_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_files" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "fileId" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_files"("id", "scenarioId", "fileId", "createdAt") SELECT "id", "scenarioId", "fileId", "createdAt" FROM "temporary_scenario_files"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_files"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenarios" RENAME TO "temporary_scenarios"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenarios" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text, "environmentId" varchar, "timeoutSeconds" integer, "version" integer NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenarios"("id", "name", "description", "environmentId", "timeoutSeconds", "version", "createdAt", "updatedAt") SELECT "id", "name", "description", "environmentId", "timeoutSeconds", "version", "createdAt", "updatedAt" FROM "temporary_scenarios"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenarios"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_steps" RENAME TO "temporary_scenario_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_steps" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "order" integer NOT NULL DEFAULT (0), "title" text, "execCode" text, "timeoutSeconds" integer, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_steps"("id", "scenarioId", "order", "title", "execCode", "timeoutSeconds", "createdAt", "updatedAt") SELECT "id", "scenarioId", "order", "title", "execCode", "timeoutSeconds", "createdAt", "updatedAt" FROM "temporary_scenario_steps"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_steps"`);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`ALTER TABLE "scenario_credentials" RENAME TO "temporary_scenario_credentials"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`CREATE TABLE "scenario_credentials" ("id" varchar PRIMARY KEY NOT NULL, "scenarioId" varchar NOT NULL, "credentialId" varchar NOT NULL, "alias" varchar NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_02756536236c408dbb58b3fc964" UNIQUE ("scenarioId", "alias"))`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(
|
|
|
|
|
`INSERT INTO "scenario_credentials"("id", "scenarioId", "credentialId", "alias", "createdAt") SELECT "id", "scenarioId", "credentialId", "alias", "createdAt" FROM "temporary_scenario_credentials"`,
|
|
|
|
|
);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "temporary_scenario_credentials"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "snippet_versions"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "snippets"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_versions"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_logs"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_files"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_runs"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_run_steps"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "sessions"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_files"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenarios"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_steps"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "scenario_credentials"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "files"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "environments"`);
|
|
|
|
|
await queryRunner.query(`DROP TABLE "credentials"`);
|
|
|
|
|
}
|
|
|
|
|
}
|