---
title: "Schema Generator API"
url: "https://effect-auth.itsbroly.com/infrastructure/schema-generator-api/"
description: "Generate selective migrations, Drizzle schemas, and focused development seeds for PostgreSQL or SQLite/D1."
---





The public storage artifact generator is available at:

```text
https://effect-auth.itsbroly.com/api/generator/v1
```

It is a stateless, deterministic Cloudflare Worker API for the interactive builder, automation, and coding agents. It emits fresh-install PostgreSQL or SQLite migration SQL, matching Drizzle declarations, and development-only seed launchers. Select `sqlite` for Cloudflare D1 artifacts.

The generated migration and Drizzle schema cover every catalog feature and table. They are DDL/catalog output, not a claim that a first-party runtime adapter implements every selected domain port.

<StorageSchemaBuilder />

## Runtime support boundary [#runtime-support-boundary]

First-party durable direct Drizzle support covers all 42 ports tracked in the project plan across SQLite, D1, and PostgreSQL. The complete account/password slice has focused Bun, Node, and PostgreSQL compositions. Individual focused stores cover the current OAuth, token, passkey, login-security, MFA, audit-log, domain-verification, security-timeline, permission, invitation, and access-grant ports.

Other domain features and their migrations remain usable. Applications must provide their own implementations of the required public store ports until focused direct adapters land. Do not interpret generated tables as runtime parity, and do not use memory storage for production durability.

## Agent workflow [#agent-workflow]

1. Read `GET /api/generator/v1/catalog` and select a supported `database` and feature IDs.
2. Request `migration-sql`; request `drizzle-schema` as well when the application needs typed table declarations.
3. Request a development seed only from `developmentSeedTargetsByDatabase`. Seeds use focused account compositions and are available for D1 through Alchemy, Bun SQLite, Node SQLite, and PostgreSQL.
4. Write every returned `files[].path` with the exact `files[].content`.
5. Report `resolved.impliedModules` and record `generatorVersion`, `schemaVersion`, and `fingerprint`.
6. Never apply a fresh baseline to an existing database. Use reviewed upgrade migrations for an existing schema ledger.

The complete machine-readable contract is available at `GET /api/generator/v1/openapi.json`.

## Generate artifacts [#generate-artifacts]

```sh
curl "https://effect-auth.itsbroly.com/api/generator/v1/artifacts/migration-sql?database=postgres&features=password,totp&layout=module"
```

```sh
curl "https://effect-auth.itsbroly.com/api/generator/v1/artifacts/migration-sql?database=sqlite&features=password,totp&layout=module"
```

```sh
curl "https://effect-auth.itsbroly.com/api/generator/v1/artifacts/drizzle-schema?database=postgres&features=password,totp&layout=table&includeRelations=true"
```

Migration layouts are `single` and `module`. Drizzle layouts are `single`, `module`, and `table`. Logical Drizzle relations do not create foreign keys; database constraints and indexes come from migration SQL.

## Generate a bundle [#generate-a-bundle]

```sh
curl https://effect-auth.itsbroly.com/api/generator/v1/generate \
  --header "Content-Type: application/json" \
  --data '{
    "database": "postgres",
    "mode": "fresh",
    "features": ["password", "totp"],
    "outputs": [
      { "kind": "migration-sql", "layout": "single" },
      { "kind": "drizzle-schema", "layout": "table", "includeRelations": true },
      { "kind": "development-seed", "target": "postgres", "complexity": "medium" }
    ]
  }'
```

The fingerprint is a deterministic change marker, not a cryptographic integrity signature. Cacheable GET responses use a separate SHA-256 HTTP `ETag`.

## Development seed [#development-seed]

The seed creates the same 100 `userN@example.test` identities and adds password credentials only when `password` is selected. It is idempotent within its owned namespace. There is no count parameter or Faker dependency.

| Database   | Supported targets           |
| ---------- | --------------------------- |
| SQLite     | `bun-sqlite`, `node-sqlite` |
| PostgreSQL | `postgres`                  |
| D1         | `alchemy-d1`                |

The default `medium` output exports `AppDevelopmentSeedLive` and `runDevelopmentSeed`; `low` adds top-level execution. Standalone scripts require `EFFECT_AUTH_DEVELOPMENT_SEED=true` and refuse `NODE_ENV=production`.

<CalloutContainer type="error">
  <CalloutTitle>
    Development only
  </CalloutTitle>

  <CalloutDescription>
    The credentials are deliberately public and memorable. Never invoke the seed against production data or expose it through an HTTP route.
  </CalloutDescription>
</CalloutContainer>

## Fresh installs only [#fresh-installs-only]

Version 1 supports only `mode: "fresh"`. It renders the current final schema and does not replay historical transformations. Never use that output to upgrade an existing database.

## Errors [#errors]

Validation failures use a stable JSON shape:

```json
{
  "error": {
    "code": "UNKNOWN_FEATURE",
    "path": "features[0]",
    "message": "Unsupported storage feature ...",
    "suggestions": ["password", "totp"]
  }
}
```

The API accepts CORS requests because it processes only bounded declarative configuration and never accepts source code, SQL, credentials, or database connections.

