Skip to content

Commit

Permalink
fix(commands): set response entity as text (#3116)
Browse files Browse the repository at this point in the history
* fix(commands): set response entity as text

Fixes #3115

* update

* change column name
  • Loading branch information
sogehige committed Dec 19, 2019
1 parent a3559ad commit afcf7b5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bot/database/entity/commands.ts
Expand Up @@ -29,7 +29,7 @@ export class CommandsResponses {
command!: Commands;
@Column()
order!: number;
@Column()
@Column('text')
response!: string;
@Column()
stopIfExecuted!: boolean;
Expand Down
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from 'typeorm';

export class commandResponsesResponseToText1576758423496 implements MigrationInterface {
name = 'commandResponsesResponseToText1576758423496';

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query('ALTER TABLE `commands_responses` MODIFY COLUMN `response` text', undefined);
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query('ALTER TABLE `commands_responses` MODIFY COLUMN `response` varchar(255)', undefined);
}

}
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from 'typeorm';

export class commandResponsesResponseToText1576758423496 implements MigrationInterface {
name = 'commandResponsesResponseToText1576758423496';

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query('ALTER TABLE "commands_responses" ALTER COLUMN "response" SET DATA TYPE text', undefined);
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query('ALTER TABLE "commands_responses" ALTER COLUMN "response" SET DATA TYPE character varying', undefined);
}

}
@@ -0,0 +1,28 @@
import {MigrationInterface, QueryRunner} from 'typeorm';

export class commandResponsesResponseToText1576758423496 implements MigrationInterface {
name = 'commandResponsesResponseToText1576758423496';

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`CREATE TABLE "temporary_commands_responses" ("id" varchar PRIMARY KEY NOT NULL, "order" integer NOT NULL, "response" varchar NOT NULL, "stopIfExecuted" boolean NOT NULL, "permission" varchar NOT NULL, "filter" varchar NOT NULL, "commandId" varchar, CONSTRAINT "FK_09da90fa3264f486de9be57b185" FOREIGN KEY ("commandId") REFERENCES "commands" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`, undefined);
await queryRunner.query(`INSERT INTO "temporary_commands_responses"("id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId") SELECT "id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId" FROM "commands_responses"`, undefined);
await queryRunner.query(`DROP TABLE "commands_responses"`, undefined);
await queryRunner.query(`ALTER TABLE "temporary_commands_responses" RENAME TO "commands_responses"`, undefined);
await queryRunner.query(`CREATE TABLE "temporary_commands_responses" ("id" varchar PRIMARY KEY NOT NULL, "order" integer NOT NULL, "response" text NOT NULL, "stopIfExecuted" boolean NOT NULL, "permission" varchar NOT NULL, "filter" varchar NOT NULL, "commandId" varchar, CONSTRAINT "FK_09da90fa3264f486de9be57b185" FOREIGN KEY ("commandId") REFERENCES "commands" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`, undefined);
await queryRunner.query(`INSERT INTO "temporary_commands_responses"("id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId") SELECT "id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId" FROM "commands_responses"`, undefined);
await queryRunner.query(`DROP TABLE "commands_responses"`, undefined);
await queryRunner.query(`ALTER TABLE "temporary_commands_responses" RENAME TO "commands_responses"`, undefined);
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "commands_responses" RENAME TO "temporary_commands_responses"`, undefined);
await queryRunner.query(`CREATE TABLE "commands_responses" ("id" varchar PRIMARY KEY NOT NULL, "order" integer NOT NULL, "response" varchar NOT NULL, "stopIfExecuted" boolean NOT NULL, "permission" varchar NOT NULL, "filter" varchar NOT NULL, "commandId" varchar, CONSTRAINT "FK_09da90fa3264f486de9be57b185" FOREIGN KEY ("commandId") REFERENCES "commands" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`, undefined);
await queryRunner.query(`INSERT INTO "commands_responses"("id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId") SELECT "id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId" FROM "temporary_commands_responses"`, undefined);
await queryRunner.query(`DROP TABLE "temporary_commands_responses"`, undefined);
await queryRunner.query(`ALTER TABLE "commands_responses" RENAME TO "temporary_commands_responses"`, undefined);
await queryRunner.query(`CREATE TABLE "commands_responses" ("id" varchar PRIMARY KEY NOT NULL, "order" integer NOT NULL, "response" varchar NOT NULL, "stopIfExecuted" boolean NOT NULL, "permission" varchar NOT NULL, "filter" varchar NOT NULL, "commandId" varchar, CONSTRAINT "FK_09da90fa3264f486de9be57b185" FOREIGN KEY ("commandId") REFERENCES "commands" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`, undefined);
await queryRunner.query(`INSERT INTO "commands_responses"("id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId") SELECT "id", "order", "response", "stopIfExecuted", "permission", "filter", "commandId" FROM "temporary_commands_responses"`, undefined);
await queryRunner.query(`DROP TABLE "temporary_commands_responses"`, undefined);
}

}

0 comments on commit afcf7b5

Please sign in to comment.