2018-12-15 17:04:04 +02:00
|
|
|
import { MigrationInterface, QueryRunner, Table } from "typeorm";
|
|
|
|
|
|
|
|
export class CreateSlowmodeTables1544877081073 implements MigrationInterface {
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<any> {
|
|
|
|
await queryRunner.createTable(
|
|
|
|
new Table({
|
|
|
|
name: "slowmode_channels",
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: "guild_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2018-12-15 17:04:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "channel_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2018-12-15 17:04:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "slowmode_seconds",
|
|
|
|
type: "int",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
|
|
|
},
|
2018-12-15 17:04:04 +02:00
|
|
|
],
|
2019-11-02 22:11:26 +02:00
|
|
|
indices: [],
|
|
|
|
}),
|
2018-12-15 17:04:04 +02:00
|
|
|
);
|
|
|
|
await queryRunner.createPrimaryKey("slowmode_channels", ["guild_id", "channel_id"]);
|
|
|
|
|
|
|
|
await queryRunner.createTable(
|
|
|
|
new Table({
|
|
|
|
name: "slowmode_users",
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: "guild_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2018-12-15 17:04:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "channel_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2018-12-15 17:04:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "user_id",
|
|
|
|
type: "bigint",
|
2019-11-02 22:11:26 +02:00
|
|
|
unsigned: true,
|
2018-12-15 17:04:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "expires_at",
|
2019-11-02 22:11:26 +02:00
|
|
|
type: "datetime",
|
|
|
|
},
|
2018-12-15 17:04:04 +02:00
|
|
|
],
|
|
|
|
indices: [
|
|
|
|
{
|
2019-11-02 22:11:26 +02:00
|
|
|
columnNames: ["expires_at"],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2018-12-15 17:04:04 +02:00
|
|
|
);
|
|
|
|
await queryRunner.createPrimaryKey("slowmode_users", ["guild_id", "channel_id", "user_id"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<any> {
|
2018-12-15 17:38:34 +02:00
|
|
|
await Promise.all([
|
|
|
|
queryRunner.dropTable("slowmode_channels", true),
|
2019-11-02 22:11:26 +02:00
|
|
|
queryRunner.dropTable("slowmode_users", true),
|
2018-12-15 17:38:34 +02:00
|
|
|
]);
|
2018-12-15 17:04:04 +02:00
|
|
|
}
|
|
|
|
}
|