3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-22 09:15:03 +00:00

Prepare to migrate usernames to a new table

This commit is contained in:
Dragory 2019-05-03 22:25:03 +03:00
parent 1f33f1d3f1
commit 133eb0ddad
4 changed files with 125 additions and 16 deletions

View file

@ -0,0 +1,46 @@
import { MigrationInterface, QueryRunner, Table } from "typeorm";
export class CreateUsernameHistoryTable1556908589679 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createTable(
new Table({
name: "username_history",
columns: [
{
name: "id",
type: "int",
unsigned: true,
isGenerated: true,
generationStrategy: "increment",
isPrimary: true,
},
{
name: "user_id",
type: "bigint",
unsigned: true,
},
{
name: "username",
type: "varchar",
length: "160",
isNullable: true,
},
{
name: "timestamp",
type: "datetime",
default: "CURRENT_TIMESTAMP",
},
],
indices: [
{
columnNames: ["user_id"],
},
],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropTable("username_history", true);
}
}