2019-01-06 15:27:51 +02:00
|
|
|
import { MigrationInterface, QueryRunner, Table } from "typeorm";
|
|
|
|
|
|
|
|
export class CreateNameHistoryTable1546778415930 implements MigrationInterface {
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<any> {
|
|
|
|
await queryRunner.createTable(
|
|
|
|
new Table({
|
|
|
|
name: "name_history",
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: "id",
|
|
|
|
type: "int",
|
|
|
|
unsigned: true,
|
|
|
|
isGenerated: true,
|
|
|
|
generationStrategy: "increment",
|
2019-11-02 22:11:26 +02:00
|
|
|
isPrimary: true,
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "guild_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "user_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "type",
|
|
|
|
type: "tinyint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "value",
|
|
|
|
type: "varchar",
|
|
|
|
length: "128",
|
2019-11-02 22:11:26 +02:00
|
|
|
isNullable: true,
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "timestamp",
|
|
|
|
type: "datetime",
|
2019-11-02 22:11:26 +02:00
|
|
|
default: "CURRENT_TIMESTAMP",
|
|
|
|
},
|
2019-01-06 15:27:51 +02:00
|
|
|
],
|
|
|
|
indices: [
|
|
|
|
{
|
2019-11-02 22:11:26 +02:00
|
|
|
columnNames: ["guild_id", "user_id"],
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
2019-11-02 22:11:26 +02:00
|
|
|
columnNames: ["type"],
|
2019-01-06 15:27:51 +02:00
|
|
|
},
|
|
|
|
{
|
2019-11-02 22:11:26 +02:00
|
|
|
columnNames: ["timestamp"],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2019-01-06 15:27:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<any> {
|
|
|
|
await queryRunner.dropTable("name_history");
|
|
|
|
}
|
|
|
|
}
|