2022-03-30 17:18:16 -04:00
|
|
|
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
|
2022-03-29 22:17:08 -04:00
|
|
|
|
|
|
|
export class AddChatRoom1648605030863 implements MigrationInterface {
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
await queryRunner.createTable(
|
|
|
|
new Table({
|
2022-03-30 17:18:16 -04:00
|
|
|
name: 'chat_room',
|
2022-03-29 22:17:08 -04:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: 'id',
|
|
|
|
type: 'int',
|
|
|
|
isPrimary: true,
|
|
|
|
isGenerated: true,
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 17:18:16 -04:00
|
|
|
name: 'userId',
|
|
|
|
type: 'int',
|
2022-03-29 22:17:08 -04:00
|
|
|
isNullable: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'latitude',
|
|
|
|
type: 'float',
|
|
|
|
isNullable: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'longitude',
|
|
|
|
type: 'float',
|
|
|
|
isNullable: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'radius',
|
|
|
|
type: 'float',
|
|
|
|
isNullable: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
);
|
2022-03-30 17:18:16 -04:00
|
|
|
|
|
|
|
await queryRunner.createForeignKey(
|
|
|
|
'chat_room',
|
|
|
|
new TableForeignKey({
|
|
|
|
columnNames: ['userId'],
|
|
|
|
referencedColumnNames: ['id'],
|
|
|
|
referencedTableName: 'user',
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
}),
|
|
|
|
);
|
2022-03-29 22:17:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
2022-03-30 17:18:16 -04:00
|
|
|
await queryRunner.dropTable('chat_room');
|
2022-03-29 22:17:08 -04:00
|
|
|
}
|
|
|
|
}
|