{
  "slug": "prisma-schema-to-sql",
  "name": "gizza-ai/prisma-schema-to-sql",
  "version": "0.1.0",
  "title": "Prisma Schema to SQL — schema.prisma to CREATE TABLE DDL — gizza.ai",
  "description": "Convert a Prisma schema into SQL CREATE TABLE DDL — columns, primary keys, indexes, enums and foreign keys — for PostgreSQL, MySQL, SQLite or SQL Server, in your browser.",
  "tags": [
    "prisma schema to sql",
    "prisma to ddl",
    "schema.prisma to create table",
    "prisma migrate diff alternative",
    "prisma to postgres ddl",
    "prisma to mysql ddl",
    "prisma sql generator",
    "prisma schema converter",
    "create table generator"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/prisma-schema-to-sql/",
    "markdown": "https://gizza.ai/tools/prisma-schema-to-sql/index.md",
    "descriptor": "https://gizza.ai/tools/prisma-schema-to-sql/tool.json",
    "deep_link_example": "https://gizza.ai/tools/prisma-schema-to-sql/?input=model%20User%20%7B%0A%20%20id%20%20%20%20Int%20%20%20%20%20%40id%20%40default%28autoincrement%28%29%29%0A%20%20email%20String%20%20%40unique%0A%20%20name%20%20String%3F%0A%7D&dialect=auto&foreign_keys=true&indexes=true&if_not_exists=true&drop_if_exists=true&quote_identifiers=true"
  },
  "cli": "gizza tool prisma-schema-to-sql \"model User {\n  id    Int     @id @default(autoincrement())\n  email String  @unique\n  name  String?\n}\"",
  "tool": {
    "description": "Convert a Prisma schema.prisma into SQL CREATE TABLE DDL. Each `model` becomes a CREATE TABLE with columns typed the way Prisma's own migrations type them for the chosen provider (String/Boolean/Int/BigInt/Float/Decimal/DateTime/Json/Bytes, `@db.*` native types used verbatim), NOT NULL for required fields, DEFAULT for literals, now() and dbgenerated() (client-side uuid()/cuid()/ulid() produce no database default), and auto-increment as SERIAL, AUTO_INCREMENT, AUTOINCREMENT or IDENTITY(1,1). `@id`/`@@id` become PRIMARY KEY constraints, `@unique`/`@@unique`/`@@index` become CREATE [UNIQUE] INDEX statements, `@map`/`@@map` rename columns/tables, `enum` blocks become a CREATE TYPE (postgresql), an inline ENUM(...) column (mysql) or a CHECK constraint (sqlite, sqlserver), and `@relation` foreign keys become ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY with ON DELETE/ON UPDATE actions. Implicit many-to-many relations get their `_AToB` join table. Optional toggles add IF NOT EXISTS guards, DROP TABLE IF EXISTS statements, or drop identifier quoting. Supports PostgreSQL, MySQL/MariaDB, SQLite and SQL Server; `auto` reads the schema's datasource provider. It is a lenient parser, not a database: nothing is executed and no connection is made.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "dialect": {
          "default": "auto",
          "description": "Target SQL dialect for the generated DDL. `auto` reads the schema's `datasource` provider and falls back to postgresql when there is none. The dialect picks the column types (String → TEXT on postgresql, VARCHAR(191) on mysql, NVARCHAR(1000) on sqlserver), the auto-increment syntax (SERIAL / AUTO_INCREMENT / AUTOINCREMENT / IDENTITY(1,1)), the identifier quoting and how enums are emitted. Default auto.",
          "enum": [
            "auto",
            "postgresql",
            "mysql",
            "sqlite",
            "sqlserver"
          ],
          "type": "string"
        },
        "drop_if_exists": {
          "default": false,
          "description": "Prepend `DROP TABLE IF EXISTS` statements (reverse creation order, plus `DROP TYPE IF EXISTS` for postgresql enums) so the script can rebuild a scratch database from zero. Destructive — only for throwaway databases. Default false.",
          "type": "boolean"
        },
        "foreign_keys": {
          "default": true,
          "description": "Emit `ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY` statements for every `@relation(fields: […], references: […])`, including ON DELETE / ON UPDATE from onDelete/onUpdate (defaults follow Prisma: RESTRICT for required relations, SET NULL for optional ones, CASCADE on update). When false, only the plain scalar columns are emitted. Default true.",
          "type": "boolean"
        },
        "if_not_exists": {
          "default": false,
          "description": "Make the script re-runnable: `CREATE TABLE IF NOT EXISTS` on postgresql/mysql/sqlite, an `IF OBJECT_ID(…) IS NULL` guard on sqlserver, and `CREATE INDEX IF NOT EXISTS` where the dialect supports it (postgresql, sqlite). Default false.",
          "type": "boolean"
        },
        "indexes": {
          "default": true,
          "description": "Emit `CREATE UNIQUE INDEX` for `@unique`/`@@unique` and `CREATE INDEX` for `@@index`, named the way Prisma names them (Table_column_key / Table_column_idx, or the `map:` name when given). When false, no index statements are produced. Default true.",
          "type": "boolean"
        },
        "input": {
          "description": "The Prisma schema to convert. Paste the contents of schema.prisma — one or more `model` blocks (one field per line, as Prisma writes them), plus any `enum`, `datasource` and `generator` blocks, e.g. \"model User {\\n  id Int @id @default(autoincrement())\\n  email String @unique\\n}\". Max 200000 bytes. Nothing is executed.",
          "type": "string"
        },
        "quote_identifiers": {
          "default": true,
          "description": "Quote table and column names with the dialect's delimiter (\"x\" on postgresql/sqlite, `x` on mysql, [x] on sqlserver), which preserves camelCase and reserved words exactly. When false, bare unquoted identifiers are emitted. Default true.",
          "type": "boolean"
        }
      },
      "required": [
        "input"
      ],
      "type": "object"
    }
  }
}