3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 09:35:02 +00:00

DB optimizations

This commit is contained in:
Dragory 2020-06-01 22:21:42 +03:00
parent 80f6f69ccd
commit a6e650810c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
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\`
`);
}
}