3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-12 13:37:19 +00:00

DB optimizations

This commit is contained in:
Dragory 2020-06-01 22:21:42 +03:00
parent f75395b8a9
commit 2e658338b5
2 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class OptimizeMessageTimestamps1591038041635 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
// DATETIME(3) -> DATETIME(0)
await queryRunner.query(`
ALTER TABLE \`messages\`
CHANGE COLUMN \`posted_at\` \`posted_at\` DATETIME(0) NOT NULL AFTER \`data\`,
CHANGE COLUMN \`deleted_at\` \`deleted_at\` DATETIME(0) NULL DEFAULT NULL AFTER \`posted_at\`
`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
// DATETIME(0) -> DATETIME(3)
await queryRunner.query(`
ALTER TABLE \`messages\`
CHANGE COLUMN \`posted_at\` \`posted_at\` DATETIME(3) NOT NULL AFTER \`data\`,
CHANGE COLUMN \`deleted_at\` \`deleted_at\` DATETIME(3) NULL DEFAULT NULL AFTER \`posted_at\`
`);
}
}