Skip to content

Column Types

When creating migrations with shipq migrate new, you specify columns using the name:type grammar. This page documents all supported column types, the references syntax for foreign keys, and how types map to each supported database dialect.

Terminal window
shipq migrate new <table> [columns...] [--global]

Each column follows one of two patterns:

  • name:type — A regular column with a data type
  • name:references:table — A foreign key column referencing another table
TypeDescriptionPostgresMySQLSQLite
stringShort text, up to 255 charactersVARCHAR(255)VARCHAR(255)TEXT
textLong-form text, unlimited lengthTEXTTEXTTEXT
intStandard integerINTEGERINTINTEGER
bigintLarge integer (64-bit)BIGINTBIGINTINTEGER
boolBoolean true/falseBOOLEANTINYINT(1)INTEGER
floatFloating-point numberDOUBLE PRECISIONDOUBLEREAL
decimalFixed-precision decimalNUMERICDECIMALNUMERIC
datetimeDate and time with timezoneTIMESTAMPDATETIMETEXT
timestampAlias for datetimeTIMESTAMPDATETIMETEXT
binaryBinary/blob dataBYTEABLOBBLOB
jsonJSON dataJSONBJSONTEXT

Use the references type to create a foreign key column:

Terminal window
name:references:table

This creates:

  • A column named name with the appropriate integer type for the referenced table’s primary key
  • A foreign key constraint referencing the id column of the target table
Terminal window
# Single foreign key
shipq migrate new books title:string author_id:references:authors
# Multiple foreign keys
shipq migrate new order_items quantity:int price:decimal order_id:references:orders product_id:references:products
# Self-referential foreign key
shipq migrate new categories name:string parent_id:references:categories

Every table created by ShipQ automatically includes the following columns — you never need to specify them:

ColumnTypeDescription
idAuto-incrementing integerPrimary key
public_idString (nanoid)URL-safe unique public identifier
created_atTimestampSet automatically on row creation
updated_atTimestampUpdated automatically on row modification
deleted_atNullable timestampUsed for soft deletes (null = not deleted)

These columns are always present on every table and are used by generated queries, handlers, and tests.

When [db] scope = organization_id is configured in shipq.ini, an additional column is automatically injected into every new migration (unless --global is passed):

ColumnTypeDescription
organization_idreferences:organizationsForeign key for multi-tenant data isolation

See the Multi-Tenancy guide for details.

Terminal window
shipq migrate new users name:string email:string

Resulting columns: id, public_id, name, email, created_at, updated_at, deleted_at

Terminal window
shipq migrate new products name:string description:text price:decimal in_stock:bool weight:float metadata:json
Terminal window
shipq migrate new comments body:text post_id:references:posts
Terminal window
shipq migrate new events name:string starts_at:datetime ends_at:datetime

When multi-tenancy is configured, use --global for shared lookup tables:

Terminal window
shipq migrate new countries name:string code:string --global
Use caseRecommended type
Names, titles, short labelsstring
Descriptions, blog content, biostext
Counts, quantities, agesint
Very large numbers, row countsbigint
Prices, monetary valuesdecimal
Weights, measurements, percentagesfloat
Flags, toggles, on/off statesbool
Dates, times, schedulingdatetime
Flexible/schemaless datajson
File contents, encoded databinary
Foreign key to another tablereferences