TitanbaseDocs

Type system

A column's type is a string. You can use one of the recognized type names below, the name of an enum, or set nativeType to emit an exact target type verbatim. Diagnostics recognize a set of types per dialect; anything unrecognized produces a warning rather than an error.

Recognized types#

These types are recognized by diagnostics and mapped by the implemented exporters. The PostgreSQL, Prisma, and Drizzle columns below reflect the current exporter behavior.

Titanbase typePostgreSQLPrismaDrizzleMermaid
uuiduuidString @db.Uuiduuid()shows uuid
stringtextStringtext()shows string
texttextStringtext()shows text
integer / intintegerIntinteger()shows the type
smallintsmallintInt @db.SmallIntinteger()shows smallint
bigintbigintBigIntbigint({ mode: "bigint" })shows bigint
boolean / boolbooleanBooleanboolean()shows the type
decimal / numericnumericDecimalnumeric()shows the type
realrealFloat @db.Realnumeric() (approx.)shows real
floatdouble precisionFloatnumeric() (approx.)shows float
double precisiondouble precisionFloat @db.DoublePrecisionnumeric() (approx.)shows the type
datedateDateTime @db.Datedate()shows date
datetimetimestampDateTimetimestamp()shows datetime
timestamptimestampDateTime @db.Timestamptimestamp({ withTimezone: false })shows timestamp
timestamptztimestamptzDateTime @db.Timestamptztimestamp({ withTimezone: true })shows timestamptz
jsonjsonbJsonjsonb()shows json
jsonbjsonbJsonjsonb()shows jsonb
byteabyteaBytesfalls back to text() + warningshows bytea

The Mermaid exporter is a diagram: it prints the type label (your nativeType if set, otherwise type) next to each column and does not map types to a specific database.

Parameterized types via nativeType

There are no maxLength, precision, or scale fields. To pin an exact type, set nativeType. The Prisma and Drizzle exporters recognize two common parameterized forms:

nativeTypePrismaDrizzle
varchar(255)String @db.VarChar(255)varchar(..., { length: 255 })
numeric(10,2)Decimal @db.Decimal(10, 2)numeric()

When nativeType is set, the PostgreSQL exporter emits it verbatim.

PostgreSQL-specific types#

The PostgreSQL exporter also maps serial, bigserial, time, timetz, interval, money, inet, cidr, and macaddr. These are PostgreSQL-oriented; the Prisma and Drizzle exporters do not have dedicated mappings for all of them and may fall back (see below). Prefer nativeType when you need an exact, target-specific type.

Enums#

Set a column's type to an enum name to use it. The PostgreSQL exporter emits CREATE TYPE ... AS ENUM; Prisma emits an enum block; Drizzle emits a pgEnum. See Enums.

Note

Enum and column names that are not lowercase snake_case may need mapping in generated output (for example Prisma @map / @@map). Diagnostics flag unsafe identifiers as warnings — see Diagnostics.

Fallback behavior#

  • Unrecognized types are intentional, safe fallbacks, not silent failures:
    • PostgreSQL emits text and adds a warning.
    • Prisma uses String and adds a warning.
    • Drizzle uses text() and adds a warning.
  • Approximations are flagged: Drizzle currently maps floating-point types to numeric() and warns, because it does not yet emit PostgreSQL floating-point builders.
  • Defaults that don't match the column type, and enum defaults that aren't valid enum values, are reported by diagnostics and may be mapped or omitted by an exporter.

Each exporter returns these warnings alongside its output so you can review them before applying the result. See Exporters.

Planned: MySQL and SQLite mappings#

Status: Planned

MySQL and SQLite exporters do not exist yet, so there are no MySQL or SQLite type mappings to document. The dialect field accepts mysql and sqlite so diagnostics can recognize those type names, but generated output today targets PostgreSQL (and PostgreSQL-flavored Prisma and Drizzle). Dedicated MySQL and SQLite mappings will be documented when those exporters ship.