From 9aefe3747ed835c910ea23cf6202ecc4a5e5ac53 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 15 Dec 2021 21:56:29 +0100 Subject: [PATCH] Feature/migrate database schema to prisma 3 (#546) * Add migration after upgrade to prisma 3 * Update changelog --- CHANGELOG.md | 6 ++ .../migration.sql | 59 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 prisma/migrations/20211215203002_migrated_schema_to_prisma_3/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 77927e734..c89086e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Todo + +- Apply data migration (`yarn database:migrate`) + ## 1.90.0 - 14.12.2021 ### Added diff --git a/prisma/migrations/20211215203002_migrated_schema_to_prisma_3/migration.sql b/prisma/migrations/20211215203002_migrated_schema_to_prisma_3/migration.sql new file mode 100644 index 000000000..f8daaa5ce --- /dev/null +++ b/prisma/migrations/20211215203002_migrated_schema_to_prisma_3/migration.sql @@ -0,0 +1,59 @@ +-- DropForeignKey +ALTER TABLE "Access" DROP CONSTRAINT "Access_granteeUserId_fkey"; + +-- DropForeignKey +ALTER TABLE "Access" DROP CONSTRAINT "Access_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Analytics" DROP CONSTRAINT "Analytics_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "AuthDevice" DROP CONSTRAINT "AuthDevice_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Order" DROP CONSTRAINT "Order_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Settings" DROP CONSTRAINT "Settings_userId_fkey"; + +-- DropForeignKey +ALTER TABLE "Subscription" DROP CONSTRAINT "Subscription_userId_fkey"; + +-- AddForeignKey +ALTER TABLE "Access" ADD CONSTRAINT "Access_granteeUserId_fkey" FOREIGN KEY ("granteeUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Access" ADD CONSTRAINT "Access_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Analytics" ADD CONSTRAINT "Analytics_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "AuthDevice" ADD CONSTRAINT "AuthDevice_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Order" ADD CONSTRAINT "Order_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Settings" ADD CONSTRAINT "Settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- RenameIndex +ALTER INDEX "MarketData.date_symbol_unique" RENAME TO "MarketData_date_symbol_key"; + +-- RenameIndex +ALTER INDEX "MarketData.symbol_index" RENAME TO "MarketData_symbol_idx"; + +-- RenameIndex +ALTER INDEX "Platform.url_unique" RENAME TO "Platform_url_key"; + +-- RenameIndex +ALTER INDEX "SymbolProfile.dataSource_symbol_unique" RENAME TO "SymbolProfile_dataSource_symbol_key";