this also needs cascades
This commit is contained in:
parent
eb5f66e4cd
commit
70fd84dd0f
35
src/migration/1663178807737-cascadeauthorization.ts
Normal file
35
src/migration/1663178807737-cascadeauthorization.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class cascadeauthorization1663178807737 implements MigrationInterface {
|
||||
name = 'cascadeauthorization1663178807737';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` DROP FOREIGN KEY \`FK_8227110f58510b7233f3db90cfb\``,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` ADD CONSTRAINT \`FK_8227110f58510b7233f3db90cfb\` FOREIGN KEY (\`userId\`) REFERENCES \`user\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` DROP FOREIGN KEY \`FK_9ca9ebb654e7ce71954d5fdb281\``,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` ADD CONSTRAINT \`FK_9ca9ebb654e7ce71954d5fdb281\` FOREIGN KEY (\`clientId\`) REFERENCES \`o_auth2_client\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` DROP FOREIGN KEY \`FK_8227110f58510b7233f3db90cfb\``,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` DROP FOREIGN KEY \`FK_9ca9ebb654e7ce71954d5fdb281\``,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` ADD CONSTRAINT \`FK_8227110f58510b7233f3db90cfb\` FOREIGN KEY (\`userId\`) REFERENCES \`user\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE \`o_auth2_client_authorization\` ADD CONSTRAINT \`FK_9ca9ebb654e7ce71954d5fdb281\` FOREIGN KEY (\`clientId\`) REFERENCES \`o_auth2_client\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
@ -22,9 +22,9 @@ export class OAuth2ClientAuthorization {
|
||||
@CreateDateColumn()
|
||||
public created_at: Date;
|
||||
|
||||
@ManyToOne(() => OAuth2Client)
|
||||
@ManyToOne(() => OAuth2Client, { onDelete: 'CASCADE' })
|
||||
public client: OAuth2Client;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
public user: User;
|
||||
}
|
||||
|
Reference in New Issue
Block a user