diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-01 16:04:00 -0600 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-01 16:04:00 -0600 |
commit | dbb9eea25f80e7984a112409863be5191af5bf5e (patch) | |
tree | cca24e23afc5e7bb4b92a0582aaec48f6a08af72 /server/database/migrations | |
parent | 1108970a6aeb98a2f113383c6437dd4d862dae10 (diff) | |
download | locchat-dbb9eea25f80e7984a112409863be5191af5bf5e.tar.gz locchat-dbb9eea25f80e7984a112409863be5191af5bf5e.zip |
Added way too much stuff
Diffstat (limited to 'server/database/migrations')
-rw-r--r-- | server/database/migrations/1648605030863-AddChatRoom.ts | 5 | ||||
-rw-r--r-- | server/database/migrations/1648844808010-AddConnectedUsers.ts | 54 |
2 files changed, 59 insertions, 0 deletions
diff --git a/server/database/migrations/1648605030863-AddChatRoom.ts b/server/database/migrations/1648605030863-AddChatRoom.ts index 747cdd3..e50f049 100644 --- a/server/database/migrations/1648605030863-AddChatRoom.ts +++ b/server/database/migrations/1648605030863-AddChatRoom.ts @@ -43,6 +43,11 @@ export class AddChatRoom1648605030863 implements MigrationInterface { type: 'varchar', isNullable: true, }, + { + name: 'lastConnection', + type: 'timestamp', + default: 'now()', + }, ], }), true, diff --git a/server/database/migrations/1648844808010-AddConnectedUsers.ts b/server/database/migrations/1648844808010-AddConnectedUsers.ts new file mode 100644 index 0000000..e6d16fe --- /dev/null +++ b/server/database/migrations/1648844808010-AddConnectedUsers.ts @@ -0,0 +1,54 @@ +import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm'; + +export class AddConnectedUsers1648844808010 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.createTable( + new Table({ + name: 'chat_room_connection', + columns: [ + { + name: 'id', + type: 'int', + isPrimary: true, + isGenerated: true, + }, + { + name: 'userId', + type: 'int', + isNullable: false, + }, + { + name: 'chatRoomId', + type: 'text', + isNullable: false, + }, + ], + }), + true, + ); + + await queryRunner.createForeignKey( + 'chat_room_connection', + new TableForeignKey({ + columnNames: ['userId'], + referencedColumnNames: ['id'], + referencedTableName: 'user', + onDelete: 'CASCADE', + }), + ); + + await queryRunner.createForeignKey( + 'chat_room_connection', + new TableForeignKey({ + columnNames: ['chatRoomId'], + referencedColumnNames: ['id'], + referencedTableName: 'chat_room', + onDelete: 'CASCADE', + }), + ); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.dropTable('connected_users'); + } +} |