calcom/packages/prisma/migrations/20220502154345_adds_apps/migration.sql
Omar López 2e6bc5e5b4 Fixes/app store keys in db (#2651)
* Adds available apps

* Adds App Model

* WIP

* Updates seeder script

* Seeder fixes

* lowercase categories

* Upgrades prisma

* WIP

* WIP

* Hopefully fixes circular deps

* Type fixes

* Fixes seeder

* Adds migration to connect Credentials to Apps

* Updates app store callbacks

* Updates google credentials

* Uses dirName from DB

* Type fixes

* Update reschedule.ts

* Seeder fixes

* Fixes categories listing

* Update index.ts

* Update schema.prisma

* Updates dependencies

* Renames giphy app

* Uses dynamic imports for app metadata

* Fixes credentials error

* Uses dynamic import for api handlers

* Dynamic import fixes

* Allows for simple folder names in app store

* Squashes app migrations

* seeder fixes

* Fixes dyamic imports

* Update apiHandlers.tsx
2022-05-02 16:21:11 -06:00

43 lines
2 KiB
SQL

-- CreateEnum
CREATE TYPE "AppCategories" AS ENUM ('calendar', 'messaging', 'other', 'payment', 'video', 'web3');
-- AlterTable
ALTER TABLE "Credential" ADD COLUMN "appId" TEXT;
-- CreateTable
CREATE TABLE "App" (
"slug" TEXT NOT NULL,
"dirName" TEXT NOT NULL,
"keys" JSONB,
"categories" "AppCategories"[],
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "App_pkey" PRIMARY KEY ("slug")
);
-- CreateIndex
CREATE UNIQUE INDEX "App_slug_key" ON "App"("slug");
-- CreateIndex
CREATE UNIQUE INDEX "App_dirName_key" ON "App"("dirName");
-- AddForeignKey
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App"("slug") ON DELETE CASCADE ON UPDATE CASCADE;
-- Connects each saved Credential to their respective App
UPDATE "Credential" SET "appId" = 'apple-calendar' WHERE "type" = 'apple_calendar';
UPDATE "Credential" SET "appId" = 'caldav-calendar' WHERE "type" = 'caldav_calendar';
UPDATE "Credential" SET "appId" = 'google-calendar' WHERE "type" = 'google_calendar';
UPDATE "Credential" SET "appId" = 'google-meet' WHERE "type" = 'google_video';
UPDATE "Credential" SET "appId" = 'office365-calendar' WHERE "type" = 'office365_calendar';
UPDATE "Credential" SET "appId" = 'msteams' WHERE "type" = 'office365_video';
UPDATE "Credential" SET "appId" = 'dailyvideo' WHERE "type" = 'daily_video';
UPDATE "Credential" SET "appId" = 'tandem' WHERE "type" = 'tandem_video';
UPDATE "Credential" SET "appId" = 'zoom' WHERE "type" = 'zoom_video';
UPDATE "Credential" SET "appId" = 'jitsi' WHERE "type" = 'jitsi_video';
UPDATE "Credential" SET "appId" = 'hubspot' WHERE "type" = 'hubspot_other_calendar';
UPDATE "Credential" SET "appId" = 'wipe-my-cal' WHERE "type" = 'wipemycal_other';
UPDATE "Credential" SET "appId" = 'huddle01' WHERE "type" = 'huddle01_video';
UPDATE "Credential" SET "appId" = 'slack' WHERE "type" = 'slack_messaging';
UPDATE "Credential" SET "appId" = 'stripe' WHERE "type" = 'stripe_payment';