ORT-SQL(1)

NAME
ort-sql - produce ort SQL schema

SYNOPSIS
ort-sql [config...]

DESCRIPTION
The ort-sql utility accepts ort(5) config files, defaulting to standard input, and produces an SQL schema. The SQL generated is designed for sqlite3(1).

  SQL Commands
Output always begins with PRAGMA foreign_keys=ON regardless of whether the configuration has any references.

The schema begins of a series of CREATE TABLE SQL commands for each struct object in config. The name of the table inherits from the structure name.

Each field within each struct is mapped into a representative SQL type except the struct, which is a virtual type. The name of the column inherits from the field name.
bit | INTEGER
bitfield | INTEGER
blob | BLOB
date | INTEGER
email | TEXT
enum | INTEGER
epoch | INTEGER
int | INTEGER
password | TEXT
real | REAL
text | TEXT

Furthermore, types may have the following attributes.
actdel | ON DELETE
actup | ON UPDATE
default | DEFAULT()
rowid | PRIMARY KEY
unique | UNIQUE

If null is not specified, the SQL column is marked as NOT NULL. The default attribute is type-specific.

Reference types may contain the actup and actdel attributes map as follows:
cascade | CASCADE
default | DEFAULT
nullify | NULLIFY
restrict | RESTRICT

These are assigned as FOREIGN KEY(xxx) REFERENCE yyy(zzz) followed by the update or delete clause, if applicable.

Lastly, any unique statement on the structure is rendered as the SQL UNIQUE(xxx, ...).

EXIT STATUS

SEE ALSO
ort-sqldiff(1), sqlite3(1), ort(5)