YAML Format Reference
This page describes the YAML format used by dbtoyaml and yamltodb.
Top-level structure
schema <name>:
owner: <username>
description: <text>
table <name>:
...
Schema properties
Property |
Type |
Description |
|---|---|---|
|
string |
Schema owner |
|
string |
Schema comment |
Table properties
Property |
Type |
Description |
|---|---|---|
|
string |
Table owner |
|
string |
Table comment |
|
list |
Column definitions (list of single-key maps) |
|
map |
Primary key constraint |
|
map |
Foreign key constraints |
|
map |
Check constraints |
|
map |
Unique constraints |
Column properties
Property |
Type |
Description |
|---|---|---|
|
string |
PostgreSQL data type |
|
boolean |
NOT NULL constraint |
|
string |
Default value expression |
|
string |
Column comment |
Example
schema public:
table film:
owner: postgres
columns:
- id:
type: integer
not_null: true
- title:
type: character varying(32)
not_null: true
- release_year:
type: integer
not_null: true
- length:
type: smallint
- rating:
type: character(5)
primary_key:
film_pkey:
columns:
- id
check_constraints:
film_length_check:
columns:
- length
expression: ((length > 0) AND (length < 10000))
film_release_year_check:
columns:
- release_year
expression: (release_year >= 1888)
owner: pg_database_owner
description: standard public schema
The columns value is a list of single-key maps (one entry per column),
which matches the format produced by Pyrseas and is accepted by both
yamltodb implementations. yamltodb also accepts the equivalent map
form (columns: {id: {...}, ...}) for backward compatibility.