import * as Redacted from "effect/Redacted"; import * as Provider from "../Provider.ts"; import { Resource } from "../Resource.ts"; import type { Project } from "./Project.ts"; import type { Providers } from "./Providers.ts"; import type { DatabaseSourceInput, PrismaDatabaseRegionId } from "./Types.ts"; export interface DatabaseDev { /** * Local provider used by `alchemy dev`. * * @default "@prisma/dev" */ provider?: "@prisma/dev"; /** * Stable local server name. */ name?: string; /** * Local storage mode for the database server. * * @default "stateful" */ persistenceMode?: "stateless" | "stateful"; /** * HTTP control port for the local server. */ port?: number; /** * Direct Postgres port for the local database. */ databasePort?: number; /** * Direct Postgres port for the local shadow database. */ shadowDatabasePort?: number; /** * Enable local provider debug logging. * * @default false */ debug?: boolean; /** * Connection timeout in milliseconds for pending database clients. */ databaseConnectTimeoutMillis?: number; /** * Idle timeout in milliseconds for active database clients. */ databaseIdleTimeoutMillis?: number; /** * Connection timeout in milliseconds for pending shadow database clients. */ shadowDatabaseConnectTimeoutMillis?: number; /** * Idle timeout in milliseconds for active shadow database clients. */ shadowDatabaseIdleTimeoutMillis?: number; /** * Optional shell command to run after the local database is ready. */ migrate?: string; /** * Working directory for the migration command. */ migrateCwd?: string; /** * Maximum time to wait for the migration command before terminating it. * Must be a positive finite number. * * @default 900 */ migrateTimeoutSeconds?: number; } export interface DatabaseProps { /** * Project ID or `project.projectId` output that owns this database. */ project: string | Project; /** * Database display name. If omitted, Alchemy generates a stable physical * name so interrupted creates can be recovered without duplicating a * database. Explicit names cannot be combined with branch attachment during * initial creation because the Management API creates the database before it * attaches the branch and exposes no idempotency key. */ name?: string; /** * Region for the database. * * @default "us-east-1" */ region?: PrismaDatabaseRegionId; /** * Standalone Prisma.Database resources cannot be the project's default * database because the Management API cannot demote or promote an existing * database, making the resource impossible to destroy safely. Use * Prisma.Project to manage the project-owned default database. * * @default false */ isDefault?: false; /** * Optional source database/backup descriptor for clone or restore creation. */ source?: DatabaseSourceInput; /** * Branch ID to attach the database to. Mutually exclusive with branchGitName. */ branchId?: string | null; /** * Branch git name to attach the database to. Mutually exclusive with branchId. */ branchGitName?: string | null; /** * Local database settings for `alchemy dev`. Set to `false` to keep only * placeholder IDs. */ dev?: false | DatabaseDev; /** * Rotate the adopted database's default connection to recover its one-time * credentials. Prisma revokes the previous key on a best-effort basis and * rotation may interrupt existing consumers, so adoption leaves credentials * unset unless explicitly opted in. * * @default false */ rotateCredentialsOnAdopt?: boolean; } export interface Database extends Resource<"Prisma.Database", DatabaseProps, { /** * Prisma database ID. */ databaseId: string; /** * Prisma database display name. */ databaseName: string; /** * Project ID that owns the database. */ projectId: string; /** * Current Prisma database status. */ status: string; /** * Prisma Postgres region ID, when available. */ region: string | null; /** * Whether this is the project's default database. */ isDefault: boolean; /** * Branch ID attached to the database, or null when unassigned. */ branchId: string | null; /** * Default connection ID for the database. */ defaultConnectionId: string | null; /** * ISO timestamp when the database was created. */ createdAt: string; /** * Direct Postgres connection string, redacted in state. */ directConnectionString: Redacted.Redacted | undefined; /** * Pooled Postgres connection string, redacted in state. */ pooledConnectionString: Redacted.Redacted | undefined; /** * Accelerate connection string, redacted in state. */ accelerateConnectionString: Redacted.Redacted | undefined; /** * Direct database host, when returned by Prisma. */ host: string | null | undefined; /** * Direct database username, when returned by Prisma. */ user: string | null | undefined; /** * Direct database password, redacted in state. */ password: Redacted.Redacted | undefined; }, never, Providers> { } /** * A Prisma Postgres database inside a Prisma project. * * Standalone `Prisma.Database` resources cannot be the project's default * database. Use `Prisma.Project` when the project should own a default * database. Project, region, and source changes require replacement; display * name and branch attachment can converge in place. Destroying this resource * deletes its database and data. * * ### Creating a Database * **Example:** Database in a project * ```typescript * const project = yield* Prisma.Project("app", { createDatabase: false }); * const database = yield* Prisma.Database("db", { * project, * region: "us-east-1", * }); * ``` * * **Example:** Database attached to a preview branch * ```typescript * const database = yield* Prisma.Database("preview-db", { * project, * branchId: preview.branchId, * }); * ``` * * @resource */ export declare const Database: import("../Resource.ts").ResourceClass; export declare const DatabaseProvider: () => import("effect/Layer").Layer, never, any>; //# sourceMappingURL=Database.d.ts.map