zappyzep/backend/src/migrations/1575199835233-CreateStatsTable.ts

60 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-12-01 15:57:35 +02:00
import { MigrationInterface, QueryRunner, Table } from "typeorm";
export class CreateStatsTable1575199835233 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(
new Table({
name: "stats",
columns: [
{
name: "id",
type: "bigint",
unsigned: true,
isPrimary: true,
generationStrategy: "increment",
},
{
name: "guild_id",
type: "bigint",
unsigned: true,
},
{
name: "source",
type: "varchar",
length: "64",
collation: "ascii_bin",
},
{
name: "key",
type: "varchar",
length: "64",
collation: "ascii_bin",
},
{
name: "value",
type: "integer",
unsigned: true,
},
{
name: "created_at",
type: "datetime",
default: "NOW()",
},
],
indices: [
{
columnNames: ["guild_id", "source", "key"],
},
{
columnNames: ["created_at"],
},
],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable("stats");
}
}