Skip to content

Commit

Permalink
Merge pull request #674 from stiftelsen-effekt/dev-branch-migration-f…
Browse files Browse the repository at this point in the history
…ixes

Dev branch migration fixes
  • Loading branch information
fellmirr authored Sep 13, 2023
2 parents 8e30152 + 633921c commit c9a0b23
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
ALTER TABLE `Swish_order` RENAME TO `Swish_orders`;

-- DropForeignKey
ALTER TABLE `Swish_orders` DROP FOREIGN KEY `Swish_order_KID_fkey`;

-- DropForeignKey
ALTER TABLE `Swish_orders` DROP FOREIGN KEY `Swish_order_donationID_fkey`;

-- DropForeignKey
ALTER TABLE `Swish_orders` DROP FOREIGN KEY `Swish_order_donorID_fkey`;

-- AddForeignKey
ALTER TABLE `Swish_orders` ADD CONSTRAINT `Swish_orders_KID_fkey` FOREIGN KEY (`KID`) REFERENCES `Distributions`(`KID`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Swish_orders` ADD CONSTRAINT `Swish_orders_donorID_fkey` FOREIGN KEY (`donorID`) REFERENCES `Donors`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
-- DropForeignKey
ALTER TABLE `Swish_orders` DROP FOREIGN KEY `Swish_orders_KID_fkey`;

-- DropIndex
DROP INDEX `Swish_order_KID_key` ON `Swish_orders`;

-- Add new normal (non-unique) index
CREATE INDEX `Swish_orders_KID_key` ON `Swish_orders`(`KID`);

-- AddForeignKey
ALTER TABLE `Swish_orders` ADD CONSTRAINT `Swish_orders_KID_fkey` FOREIGN KEY (`KID`) REFERENCES `Distributions`(`KID`) ON DELETE CASCADE ON UPDATE CASCADE;
4 changes: 4 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ async function main() {
await prisma.data_owner.createMany({ data: fakeDataOwner });
await prisma.payment.createMany({ data: fakePayments });
await prisma.donors.createMany({ data: fakeDonors });
// Multiple cause area migrations manually creates a cause area for global health to successfully migrate
// existing production data. Thus, running the migrations in the seed file will cause a duplicate key error.
// To avoid this, we delete all cause areas before seeding.
await prisma.cause_areas.deleteMany({});
await prisma.cause_areas.createMany({ data: fakeCauseAreas });
await prisma.organizations.createMany({ data: fakeOrganizations });
await prisma.tax_unit.createMany({ data: fakeTaxUnits });
Expand Down
2 changes: 1 addition & 1 deletion src/custom_modules/DAO_modules/causeareas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cause_areas, Donations, Organizations, Swish_order } from "@prisma/client";
import { Cause_areas, Organizations } from "@prisma/client";
import { DAO } from "../DAO";
import { CauseArea, Organization } from "../../schemas/types";
import { mapOrganization } from "./organizations";
Expand Down
2 changes: 0 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ console.log("Top level dependencies loaded");
DAO.connect(() => {
console.log("DAO setup complete");

console.log("---------GSM----------");

//Setup express
const app = express();

Expand Down

0 comments on commit c9a0b23

Please sign in to comment.