|
1 | 1 | import { createGuestUser } from '@/lib/authUtils'; |
2 | | -import { SOURCEBOT_SUPPORT_EMAIL } from "@/lib/constants"; |
3 | 2 | import { prisma } from "@/prisma"; |
4 | 3 | import { OrgRole } from '@sourcebot/db'; |
5 | 4 | import { createLogger, env, hasEntitlement, loadConfig } from "@sourcebot/shared"; |
@@ -35,7 +34,7 @@ const pruneOldGuestUser = async () => { |
35 | 34 | } |
36 | 35 | } |
37 | 36 |
|
38 | | -const initSingleTenancy = async () => { |
| 37 | +const init = async () => { |
39 | 38 | // This is needed because v4 introduces the GUEST org role as well as making authentication required. |
40 | 39 | // To keep things simple, we'll just delete the old guest user if it exists in the DB |
41 | 40 | await pruneOldGuestUser(); |
@@ -66,7 +65,7 @@ const initSingleTenancy = async () => { |
66 | 65 | // search contexts that may be present in the DB. This could happen if a deployment had |
67 | 66 | // the entitlement, synced search contexts, and then no longer had the entitlement |
68 | 67 | const hasSearchContextEntitlement = hasEntitlement("search-contexts") |
69 | | - if(!hasSearchContextEntitlement) { |
| 68 | + if (!hasSearchContextEntitlement) { |
70 | 69 | await prisma.searchContext.deleteMany({ |
71 | 70 | where: { |
72 | 71 | orgId: SINGLE_TENANT_ORG_ID, |
@@ -115,20 +114,6 @@ const initSingleTenancy = async () => { |
115 | 114 | } |
116 | 115 | } |
117 | 116 |
|
118 | | -const initMultiTenancy = async () => { |
119 | | - const hasMultiTenancyEntitlement = hasEntitlement("multi-tenancy"); |
120 | | - if (!hasMultiTenancyEntitlement) { |
121 | | - logger.error(`SOURCEBOT_TENANCY_MODE is set to ${env.SOURCEBOT_TENANCY_MODE} but your license doesn't have multi-tenancy entitlement. Please contact ${SOURCEBOT_SUPPORT_EMAIL} to request a license upgrade.`); |
122 | | - process.exit(1); |
123 | | - } |
124 | | -} |
125 | | - |
126 | 117 | (async () => { |
127 | | - if (env.SOURCEBOT_TENANCY_MODE === 'single') { |
128 | | - await initSingleTenancy(); |
129 | | - } else if (env.SOURCEBOT_TENANCY_MODE === 'multi') { |
130 | | - await initMultiTenancy(); |
131 | | - } else { |
132 | | - throw new Error(`Invalid SOURCEBOT_TENANCY_MODE: ${env.SOURCEBOT_TENANCY_MODE}`); |
133 | | - } |
| 118 | + await init(); |
134 | 119 | })(); |
0 commit comments