add sync customer command and drop subscription customer constraint (#9131)
**TLDR:** Solves (https://github.com/twentyhq/private-issues/issues/212) Add command to sync customer data from stripe to BillingCustomerTable for all active workspaces. Drop foreign key contraint on billingCustomer in BillingSubscription (in order to not break the DB). **In order to test:** - Billing should be enabled - Have some workspaces that are active and whose id's are not mentioned in BillingCustomer (but the customer are present in stripe). Run the command: `npx nx run twenty-server:command billing:sync-customer-data` Take into consideration Due that all the previous subscriptions in Stripe have the workspaceId in their metadata, we use that information as source of true for the data sync **Things to do:** - Add tests for Billing utils - Separate StripeService into multipleServices (stripeSubscriptionService, stripePriceService etc) perhaps add them in (https://github.com/twentyhq/private-issues/issues/201)?
This commit is contained in:
committed by
GitHub
parent
e84176dc0d
commit
028e5cd940
@ -30,15 +30,9 @@ export class AddConstraintsOnBillingTables1734450749954
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."billingEntitlement" ADD CONSTRAINT "FK_766a1918aa3dbe0d67d3df62356" FOREIGN KEY ("stripeCustomerId") REFERENCES "core"."billingCustomer"("stripeCustomerId") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."billingSubscription" ADD CONSTRAINT "FK_9120b7586c3471463480b58d20a" FOREIGN KEY ("stripeCustomerId") REFERENCES "core"."billingCustomer"("stripeCustomerId") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."billingSubscription" DROP CONSTRAINT "FK_9120b7586c3471463480b58d20a"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."billingEntitlement" DROP CONSTRAINT "FK_766a1918aa3dbe0d67d3df62356"`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user