Skip to content

SourceRepository

Source: src/Prisma/SourceRepository.ts

A linked source repository for Prisma apps.

GitHub is currently the only supported provider. Linking requires an existing Prisma SCM installation. providerRepositoryId is GitHub’s permanent numeric repository ID; retrieve it with gh api repos/OWNER/REPO --jq '.id'. When installationId is omitted, Prisma selects the workspace installation.

Linking creates or renames the repository-owned default branch. Observe that branch through the Management API; do not declare it again as a separate Prisma.Branch resource. Use this resource’s outputs to order downstream databases and apps after the link side effects complete. Deleting the link does not roll those side effects back: existing branches, databases, and apps remain in the project.

The project, repository ID, provider, and installation form an immutable link identity. Alchemy refuses an automatic relink because unlinking cannot roll back branch and resource attachments. Existing links require explicit adoption.

Terminal window
gh api repos/OWNER/REPO --jq '.id'
const repo = yield* Prisma.SourceRepository("repo", {
project: project.projectId,
// Replace with the value returned by the GitHub command above.
providerRepositoryId: 123456789,
});
const database = yield* Prisma.Database("database", {
project: repo.projectId,
branchGitName: repo.defaultBranch,
});