# Pams.Database

**Kind:** Module

**Source:** `Pams/PamsDatabase/../Database/Pams.Database/Pams.Database.sqlproj` (line 1)

**Part of:** [Pams](subsystem-pams)

.NET project in solution

`Pams.Database` is a SQL Server database project within the Pams solution. It defines the database schema and produces a deployable database artifact that can be published to a target SQL Server instance.

## Diagram

```mermaid
graph TD
    Solution[Pams solution] --> DatabaseProject[Pams.Database SQL project]
    DatabaseProject --> Build[Build database artifact]
    Build --> Dacpac[DACPAC package]
    Dacpac --> Publish[SqlPackage publish]
    Publish --> SqlServer[Target SQL Server database]
```

## Usage

```ts
import { execFileSync } from "node:child_process";

function publishDatabase(
  dacpacPath: string,
  connectionString: string,
): void {
  execFileSync(
    "SqlPackage",
    [
      "/Action:Publish",
      `/SourceFile:${dacpacPath}`,
      `/TargetConnectionString:${connectionString}`,
    ],
    { stdio: "inherit" },
  );
}

publishDatabase(
  process.env.PAMS_DATABASE_DACPAC_PATH!,
  process.env.PAMS_DATABASE_CONNECTION_STRING!,
);
```

## AI Coding Instructions

- Treat `Pams.Database` as a SQL Server database project, not a runtime .NET library.
- Make schema changes through project SQL files so they are included in the generated database artifact.
- Publish the built database artifact with `SqlPackage`; do not apply untracked schema changes directly to target environments.
- Keep connection strings and deployment credentials in environment variables or deployment configuration, not in SQL project files.

## Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Declared in (2)

- `PamsDatabaseSolution` — `Pams/Database/Pams.Database/PamsDatabaseSolution/PamsDatabaseSolution.sln`:1
- `PamsDatabase` — `Pams/PamsDatabase/PamsDatabase.sln`:1
