Initial dashboard work (auth flow)

This commit is contained in:
Dragory 2019-05-26 00:13:42 +03:00
parent d54897acdd
commit 5a91d36953
18 changed files with 3808 additions and 31 deletions

View file

@ -0,0 +1,54 @@
import { MigrationInterface, QueryRunner, Table } from "typeorm";
export class CreateDashboardLoginsTable1558804433320 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(
new Table({
name: "dashboard_logins",
columns: [
{
name: "id",
type: "varchar",
length: "36",
isPrimary: true,
collation: "ascii_bin",
},
{
name: "token",
type: "varchar",
length: "64",
collation: "ascii_bin",
},
{
name: "user_id",
type: "bigint",
},
{
name: "user_data",
type: "text",
},
{
name: "logged_in_at",
type: "DATETIME",
},
{
name: "expires_at",
type: "DATETIME",
},
],
indices: [
{
columnNames: ["user_id"],
},
{
columnNames: ["expires_at"],
},
],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable("dashboard_logins", true);
}
}

View file

@ -0,0 +1,43 @@
import { MigrationInterface, QueryRunner, Table, TableIndex } from "typeorm";
export class CreateDashboardUsersTable1558804449510 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(
new Table({
name: "dashboard_users",
columns: [
{
name: "guild_id",
type: "bigint",
},
{
name: "user_id",
type: "bigint",
},
{
name: "username",
type: "varchar",
length: "255",
},
{
name: "role",
type: "varchar",
length: "32",
},
],
}),
);
await queryRunner.createPrimaryKey("dashboard_users", ["guild_id", "user_id"]);
await queryRunner.createIndex(
"dashboard_users",
new TableIndex({
columnNames: ["user_id"],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable("dashboard_users", true);
}
}