Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/migrateKratosUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const migratePasswordAccounts = async (
const { rowCount } = await dailyPool.query(
`INSERT INTO ba_account (id, "userId", "providerId", "accountId", password, "createdAt", "updatedAt")
VALUES ${placeholders.join(', ')}
ON CONFLICT (id) DO NOTHING`,
ON CONFLICT ("userId", "providerId") DO NOTHING`,
values,
);
total += rowCount ?? 0;
Expand Down Expand Up @@ -229,7 +229,7 @@ const migrateOidcAccounts = async (
const { rowCount } = await dailyPool.query(
`INSERT INTO ba_account (id, "userId", "providerId", "accountId", "createdAt", "updatedAt")
VALUES ${placeholders.join(', ')}
ON CONFLICT (id) DO NOTHING`,
ON CONFLICT ("userId", "providerId") DO NOTHING`,
values,
);
total += rowCount ?? 0;
Expand Down
19 changes: 19 additions & 0 deletions src/migration/1774400000000-BaAccountUserProviderUnique.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class BaAccountUserProviderUnique1774400000000 implements MigrationInterface {
name = 'BaAccountUserProviderUnique1774400000000';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(/* sql */ `
CREATE UNIQUE INDEX IF NOT EXISTS
"IDX_ba_account_userId_providerId"
ON "ba_account" ("userId", "providerId")
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(/* sql */ `
DROP INDEX IF EXISTS "IDX_ba_account_userId_providerId"
`);
}
}
Loading