mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 14:21:46 +00:00
78 lines
1.7 KiB
TypeScript
78 lines
1.7 KiB
TypeScript
import {
|
|
type MigrationInterface,
|
|
type QueryRunner,
|
|
Table,
|
|
TableColumn,
|
|
TableForeignKey,
|
|
TableIndex,
|
|
} from 'typeorm';
|
|
|
|
export class CreateOauthConsent1777217882945 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.createTable(
|
|
new Table({
|
|
name: 'oauthConsent',
|
|
columns: [
|
|
{
|
|
name: 'id',
|
|
type: 'text',
|
|
isPrimary: true,
|
|
},
|
|
{
|
|
name: 'clientId',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'userId',
|
|
type: 'text',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'referenceId',
|
|
type: 'text',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'scopes',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
type: 'datetime',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
type: 'datetime',
|
|
isNullable: true,
|
|
},
|
|
],
|
|
}),
|
|
);
|
|
|
|
await queryRunner.createForeignKey(
|
|
'oauthConsent',
|
|
new TableForeignKey({
|
|
columnNames: ['clientId'],
|
|
referencedTableName: 'oauthClient',
|
|
referencedColumnNames: ['clientId'],
|
|
onDelete: 'CASCADE',
|
|
}),
|
|
);
|
|
|
|
await queryRunner.createForeignKey(
|
|
'oauthConsent',
|
|
new TableForeignKey({
|
|
columnNames: ['userId'],
|
|
referencedTableName: 'user',
|
|
referencedColumnNames: ['id'],
|
|
onDelete: 'CASCADE',
|
|
}),
|
|
);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.dropTable('oauthConsent');
|
|
}
|
|
}
|