mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
resolve conflict
This commit is contained in:
@@ -12,23 +12,28 @@ export class AddEmailToOtpVerifications1900000000000
|
||||
name = "AddEmailToOtpVerifications1900000000000";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// The table lives in the `freight` schema (the OtpVerification entity pins
|
||||
// schema: "freight"). An earlier version of this migration targeted
|
||||
// `public.otp_verifications`, which does not exist there — leaving the real
|
||||
// freight table without an `email` column and OTP send failing with
|
||||
// `column OtpVerification.email does not exist`. Target `freight` explicitly.
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE public.otp_verifications
|
||||
ALTER TABLE freight.otp_verifications
|
||||
ALTER COLUMN phone DROP NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE public.otp_verifications
|
||||
ALTER TABLE freight.otp_verifications
|
||||
ADD COLUMN IF NOT EXISTS email varchar UNIQUE
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE public.otp_verifications
|
||||
ALTER TABLE freight.otp_verifications
|
||||
DROP COLUMN IF EXISTS email
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE public.otp_verifications
|
||||
ALTER TABLE freight.otp_verifications
|
||||
ALTER COLUMN phone SET NOT NULL
|
||||
`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
/**
|
||||
* Repair: AddEmailToOtpVerifications1900000000000 originally altered
|
||||
* `public.otp_verifications`, but the OtpVerification entity pins
|
||||
* schema: "freight". On any DB where that migration already ran (and is recorded
|
||||
* as executed, so it won't run again), the real `freight.otp_verifications` table
|
||||
* never got the `email` column and `phone` was never made nullable — so OTP send
|
||||
* dies with `column OtpVerification.email does not exist`.
|
||||
*
|
||||
* This migration re-applies the change against the correct schema. Idempotent
|
||||
* (IF NOT EXISTS / no-op DROP NOT NULL), and guarded so it's a no-op when the
|
||||
* freight table is absent.
|
||||
*/
|
||||
export class RepairOtpEmailSchema2020000000000 implements MigrationInterface {
|
||||
name = "RepairOtpEmailSchema2020000000000";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const exists = await queryRunner.hasTable("freight.otp_verifications");
|
||||
if (!exists) return;
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE freight.otp_verifications
|
||||
ALTER COLUMN phone DROP NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE freight.otp_verifications
|
||||
ADD COLUMN IF NOT EXISTS email varchar UNIQUE
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const exists = await queryRunner.hasTable("freight.otp_verifications");
|
||||
if (!exists) return;
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE freight.otp_verifications
|
||||
DROP COLUMN IF EXISTS email
|
||||
`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user