-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor v2 migrations to make v2 columns not null after introducing …
…it as nullable field and vice versa
- Loading branch information
1 parent
5ff01f1
commit ddef69b
Showing
15 changed files
with
153 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 32 additions & 2 deletions
34
v2_migrations/2024-08-28-081722_drop_not_null_constraints_on_v1_columns/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
-- This file should undo anything in `up.sql` | ||
------------------------ Organization ----------------------- | ||
-- Re-add primary key constraint on `organization` | ||
ALTER TABLE organization ADD CONSTRAINT organization_pkey PRIMARY KEY (org_id); | ||
-- Restore `org_id` to NOT NULL | ||
ALTER TABLE organization ALTER COLUMN org_id SET NOT NULL; | ||
ALTER TABLE organization ADD PRIMARY KEY (org_id); | ||
|
||
-- Merchant Account | ||
ALTER TABLE merchant_account ADD PRIMARY KEY (merchant_id); | ||
ALTER TABLE merchant_account | ||
ALTER COLUMN primary_business_details SET NOT NULL, | ||
ALTER COLUMN is_recon_enabled SET NOT NULL, | ||
ALTER COLUMN is_recon_enabled SET DEFAULT FALSE; | ||
|
||
-- Business Profile | ||
ALTER TABLE business_profile ADD PRIMARY KEY (profile_id); | ||
|
||
-- Merchant Connector Account | ||
ALTER TABLE merchant_connector_account ADD PRIMARY KEY (merchant_connector_id); | ||
|
||
-- Customers | ||
ALTER TABLE customers ADD PRIMARY KEY (merchant_id, customer_id); | ||
|
||
-- Payment Intent | ||
ALTER TABLE payment_intent ADD PRIMARY KEY (payment_id, merchant_id); | ||
ALTER TABLE payment_intent ALTER COLUMN active_attempt_id SET NOT NULL; | ||
ALTER TABLE payment_intent ALTER COLUMN active_attempt_id SET DEFAULT 'xxx'; | ||
|
||
-- Payment Attempt | ||
ALTER TABLE payment_attempt ADD PRIMARY KEY (attempt_id, merchant_id); | ||
ALTER TABLE payment_attempt ALTER COLUMN amount SET NOT NULL; | ||
|
||
-- Payment Methods | ||
ALTER TABLE payment_methods ADD PRIMARY KEY (payment_method_id); |
39 changes: 37 additions & 2 deletions
39
v2_migrations/2024-08-28-081722_drop_not_null_constraints_on_v1_columns/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
-- Drop not null constraint on org_id in orgnaization table | ||
-- Drop not null constraint on org_id in organization table | ||
ALTER TABLE organization DROP CONSTRAINT organization_pkey; | ||
ALTER TABLE organization ALTER COLUMN org_id DROP NOT NULL; | ||
ALTER TABLE organization ALTER COLUMN org_id DROP NOT NULL; | ||
|
||
-- Drop not null in merchant_account table for v1 columns that are dropped in v2 | ||
ALTER TABLE merchant_account | ||
DROP CONSTRAINT merchant_account_pkey, | ||
ALTER COLUMN merchant_id DROP NOT NULL, | ||
ALTER COLUMN primary_business_details DROP NOT NULL, | ||
ALTER COLUMN is_recon_enabled DROP NOT NULL; | ||
|
||
ALTER TABLE business_profile | ||
DROP CONSTRAINT business_profile_pkey, | ||
ALTER COLUMN profile_id DROP NOT NULL; | ||
|
||
ALTER TABLE merchant_connector_account | ||
DROP CONSTRAINT merchant_connector_account_pkey, | ||
ALTER COLUMN merchant_connector_id DROP NOT NULL; | ||
|
||
ALTER TABLE customers | ||
DROP CONSTRAINT customers_pkey, | ||
ALTER COLUMN customer_id DROP NOT NULL; | ||
|
||
ALTER TABLE payment_intent | ||
DROP CONSTRAINT payment_intent_pkey, | ||
ALTER COLUMN payment_id DROP NOT NULL, | ||
ALTER COLUMN active_attempt_id DROP NOT NULL; | ||
|
||
ALTER TABLE payment_intent ALTER COLUMN active_attempt_id DROP DEFAULT; | ||
|
||
ALTER TABLE payment_attempt | ||
DROP CONSTRAINT payment_attempt_pkey, | ||
ALTER COLUMN attempt_id DROP NOT NULL, | ||
ALTER COLUMN amount DROP NOT NULL; | ||
|
||
ALTER TABLE payment_methods | ||
DROP CONSTRAINT payment_methods_pkey, | ||
ALTER COLUMN payment_method_id DROP NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.