Migration seeder fixes
This commit is contained in:
parent
000785c29f
commit
361579ba31
3 changed files with 26 additions and 37 deletions
|
@ -24,20 +24,3 @@ CREATE UNIQUE INDEX "App_dirName_key" ON "App"("dirName");
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_appId_fkey" FOREIGN KEY ("appId") REFERENCES "App"("slug") ON DELETE CASCADE ON UPDATE CASCADE;
|
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';
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
-- Connects each saved Credential to their respective App
|
|
||||||
UPDATE "Credential" SET "appId" = 'metamask' WHERE "type" = 'metamask_web3';
|
|
||||||
UPDATE "Credential" SET "appId" = 'giphy' WHERE "type" = 'giphy_other';
|
|
|
@ -9,6 +9,7 @@ async function createApp(
|
||||||
/** The directory name for `/packages/app-store/[dirName]` */
|
/** The directory name for `/packages/app-store/[dirName]` */
|
||||||
dirName: Prisma.AppCreateInput["dirName"],
|
dirName: Prisma.AppCreateInput["dirName"],
|
||||||
categories: Prisma.AppCreateInput["categories"],
|
categories: Prisma.AppCreateInput["categories"],
|
||||||
|
type: Prisma.CredentialCreateInput["type"],
|
||||||
keys?: Prisma.AppCreateInput["keys"]
|
keys?: Prisma.AppCreateInput["keys"]
|
||||||
) {
|
) {
|
||||||
await prisma.app.upsert({
|
await prisma.app.upsert({
|
||||||
|
@ -16,71 +17,79 @@ async function createApp(
|
||||||
create: { slug, dirName, categories, keys },
|
create: { slug, dirName, categories, keys },
|
||||||
update: { dirName, categories, keys },
|
update: { dirName, categories, keys },
|
||||||
});
|
});
|
||||||
|
await prisma.credential.updateMany({
|
||||||
|
where: { type },
|
||||||
|
data: { appId: slug },
|
||||||
|
});
|
||||||
console.log(`📲 Upserted app: '${slug}'`);
|
console.log(`📲 Upserted app: '${slug}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// Calendar apps
|
// Calendar apps
|
||||||
await createApp("apple-calendar", "applecalendar", ["calendar"]);
|
await createApp("apple-calendar", "applecalendar", ["calendar"], "apple_calendar");
|
||||||
await createApp("caldav-calendar", "caldavcalendar", ["calendar"]);
|
await createApp("caldav-calendar", "caldavcalendar", ["calendar"], "caldav_calendar");
|
||||||
try {
|
try {
|
||||||
const { client_secret, client_id, redirect_uris } = JSON.parse(process.env.GOOGLE_API_CREDENTIALS).web;
|
const { client_secret, client_id, redirect_uris } = JSON.parse(process.env.GOOGLE_API_CREDENTIALS).web;
|
||||||
await createApp("google-calendar", "googlecalendar", ["calendar"], {
|
await createApp("google-calendar", "googlecalendar", ["calendar"], "google_calendar", {
|
||||||
|
client_id,
|
||||||
|
client_secret,
|
||||||
|
redirect_uris,
|
||||||
|
});
|
||||||
|
await createApp("google-meet", "googlevideo", ["video"], "google_video", {
|
||||||
client_id,
|
client_id,
|
||||||
client_secret,
|
client_secret,
|
||||||
redirect_uris,
|
redirect_uris,
|
||||||
});
|
});
|
||||||
await createApp("google-meet", "googlevideo", ["video"], { client_id, client_secret, redirect_uris });
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error) console.error("Error adding google credentials to DB:", e.message);
|
if (e instanceof Error) console.error("Error adding google credentials to DB:", e.message);
|
||||||
}
|
}
|
||||||
if (process.env.MS_GRAPH_CLIENT_ID && process.env.MS_GRAPH_CLIENT_SECRET) {
|
if (process.env.MS_GRAPH_CLIENT_ID && process.env.MS_GRAPH_CLIENT_SECRET) {
|
||||||
await createApp("office365-calendar", "office365calendar", ["calendar"], {
|
await createApp("office365-calendar", "office365calendar", ["calendar"], "office365_calendar", {
|
||||||
client_id: process.env.MS_GRAPH_CLIENT_ID,
|
client_id: process.env.MS_GRAPH_CLIENT_ID,
|
||||||
client_secret: process.env.MS_GRAPH_CLIENT_SECRET,
|
client_secret: process.env.MS_GRAPH_CLIENT_SECRET,
|
||||||
});
|
});
|
||||||
await createApp("msteams", "office365video", ["video"]);
|
await createApp("msteams", "office365video", ["video"], "office365_video");
|
||||||
}
|
}
|
||||||
// Video apps
|
// Video apps
|
||||||
if (process.env.DAILY_API_KEY) {
|
if (process.env.DAILY_API_KEY) {
|
||||||
await createApp("dailyvideo", "dailyvideo", ["video"], {
|
await createApp("dailyvideo", "dailyvideo", ["video"], "daily_video", {
|
||||||
api_key: process.env.DAILY_API_KEY,
|
api_key: process.env.DAILY_API_KEY,
|
||||||
scale_plan: process.env.DAILY_SCALE_PLAN,
|
scale_plan: process.env.DAILY_SCALE_PLAN,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (process.env.TANDEM_CLIENT_ID && process.env.TANDEM_CLIENT_SECRET) {
|
if (process.env.TANDEM_CLIENT_ID && process.env.TANDEM_CLIENT_SECRET) {
|
||||||
await createApp("tandem", "tandemvideo", ["video"], {
|
await createApp("tandem", "tandemvideo", ["video"], "tandem_video", {
|
||||||
client_id: process.env.TANDEM_CLIENT_ID as string,
|
client_id: process.env.TANDEM_CLIENT_ID as string,
|
||||||
client_secret: process.env.TANDEM_CLIENT_SECRET as string,
|
client_secret: process.env.TANDEM_CLIENT_SECRET as string,
|
||||||
base_url: (process.env.TANDEM_BASE_URL as string) || "https://tandem.chat",
|
base_url: (process.env.TANDEM_BASE_URL as string) || "https://tandem.chat",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (process.env.ZOOM_CLIENT_ID && process.env.ZOOM_CLIENT_SECRET) {
|
if (process.env.ZOOM_CLIENT_ID && process.env.ZOOM_CLIENT_SECRET) {
|
||||||
await createApp("zoom", "zoomvideo", ["video"], {
|
await createApp("zoom", "zoomvideo", ["video"], "zoom_video", {
|
||||||
client_id: process.env.ZOOM_CLIENT_ID,
|
client_id: process.env.ZOOM_CLIENT_ID,
|
||||||
client_secret: process.env.ZOOM_CLIENT_SECRET,
|
client_secret: process.env.ZOOM_CLIENT_SECRET,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await createApp("jitsi", "jitsivideo", ["video"]);
|
await createApp("jitsi", "jitsivideo", ["video"], "jitsi_video");
|
||||||
// Other apps
|
// Other apps
|
||||||
if (process.env.HUBSPOT_CLIENT_ID && process.env.HUBSPOT_CLIENT_SECRET) {
|
if (process.env.HUBSPOT_CLIENT_ID && process.env.HUBSPOT_CLIENT_SECRET) {
|
||||||
await createApp("hubspot", "hubspotothercalendar", ["other"], {
|
await createApp("hubspot", "hubspotothercalendar", ["other"], "hubspot_other_calendar", {
|
||||||
client_id: process.env.HUBSPOT_CLIENT_ID,
|
client_id: process.env.HUBSPOT_CLIENT_ID,
|
||||||
client_secret: process.env.HUBSPOT_CLIENT_SECRET,
|
client_secret: process.env.HUBSPOT_CLIENT_SECRET,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await createApp("wipe-my-cal", "wipemycalother", ["other"]);
|
await createApp("wipe-my-cal", "wipemycalother", ["other"], "wipemycal_other");
|
||||||
if (process.env.GIPHY_API_KEY) {
|
if (process.env.GIPHY_API_KEY) {
|
||||||
await createApp("giphy", "giphy", ["other"], {
|
await createApp("giphy", "giphy", ["other"], "giphy_other", {
|
||||||
api_key: process.env.GIPHY_API_KEY,
|
api_key: process.env.GIPHY_API_KEY,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Web3 apps
|
// Web3 apps
|
||||||
await createApp("huddle01", "huddle01video", ["web3", "video"]);
|
await createApp("huddle01", "huddle01video", ["web3", "video"], "huddle01_video");
|
||||||
await createApp("metamask", "metamask", ["web3"]);
|
await createApp("metamask", "metamask", ["web3"], "metamask_web3");
|
||||||
// Messaging apps
|
// Messaging apps
|
||||||
if (process.env.SLACK_CLIENT_ID && process.env.SLACK_CLIENT_SECRET && process.env.SLACK_SIGNING_SECRET) {
|
if (process.env.SLACK_CLIENT_ID && process.env.SLACK_CLIENT_SECRET && process.env.SLACK_SIGNING_SECRET) {
|
||||||
await createApp("slack", "slackmessaging", ["messaging"], {
|
await createApp("slack", "slackmessaging", ["messaging"], "slack_messaging", {
|
||||||
client_id: process.env.SLACK_CLIENT_ID,
|
client_id: process.env.SLACK_CLIENT_ID,
|
||||||
client_secret: process.env.SLACK_CLIENT_SECRET,
|
client_secret: process.env.SLACK_CLIENT_SECRET,
|
||||||
signing_secret: process.env.SLACK_SIGNING_SECRET,
|
signing_secret: process.env.SLACK_SIGNING_SECRET,
|
||||||
|
@ -93,7 +102,7 @@ async function main() {
|
||||||
process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY &&
|
process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY &&
|
||||||
process.env.STRIPE_WEBHOOK_SECRET
|
process.env.STRIPE_WEBHOOK_SECRET
|
||||||
) {
|
) {
|
||||||
await createApp("stripe", "stripepayment", ["payment"], {
|
await createApp("stripe", "stripepayment", ["payment"], "stripe_payment", {
|
||||||
client_id: process.env.STRIPE_CLIENT_ID,
|
client_id: process.env.STRIPE_CLIENT_ID,
|
||||||
client_secret: process.env.STRIPE_PRIVATE_KEY,
|
client_secret: process.env.STRIPE_PRIVATE_KEY,
|
||||||
payment_fee_fixed: 10,
|
payment_fee_fixed: 10,
|
||||||
|
|
Loading…
Reference in a new issue