MCPcopy
hub / github.com/prisma/prisma / link

Method link

packages/cli/src/postgres/link/Link.ts:214–234  ·  view source on GitHub ↗
(
    apiKey: string | undefined,
    databaseId: string | undefined,
    baseDir: string,
    opts?: { force?: boolean },
  )

Source from the content-addressed store, hash-verified

212 }
213
214 async link(
215 apiKey: string | undefined,
216 databaseId: string | undefined,
217 baseDir: string,
218 opts?: { force?: boolean },
219 ): Promise<LinkResult> {
220 if (!opts?.force && isAlreadyLinked(baseDir)) {
221 throw new LinkApiError('This project is already linked to Prisma Postgres. Use force to re-link.')
222 }
223
224 try {
225 return await this.executeLinkFlow(apiKey, databaseId, baseDir)
226 } catch (err) {
227 if (!apiKey && isExpiredSessionError(err)) {
228 console.log(`Session expired. Re-authenticating via browser...`)
229 await login({ utmMedium: 'command-postgres-link' })
230 return await this.executeLinkFlow(apiKey, databaseId, baseDir)
231 }
232 throw err
233 }
234 }
235
236 private async executeLinkFlow(
237 apiKey: string | undefined,

Callers 1

runMethod · 0.80

Calls 5

executeLinkFlowMethod · 0.95
isAlreadyLinkedFunction · 0.90
loginFunction · 0.90
isExpiredSessionErrorFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected