Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev branch migration fixes #674

Merged
merged 4 commits into from
Sep 13, 2023
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
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