SQLite Schema
schema
The schema
block describes a database schema.
schema "public" {
...
}
Attributes
Name | Required | Value |
---|---|---|
comment | false | string |
name | false | string |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table
The table
block describes a table in a database schema.
table "users" {
schema = schema.public
column "id" {
type = int
}
...
}
Attributes
Name | Required | Value |
---|---|---|
comment | false | string |
schema | true | Object reference to |
strict | false | bool |
without_rowid | false | bool |
Blocks
table.check
table.check
attributes
Name | Required | Value |
---|---|---|
comment | false | string |
expr | true | string |
table.check
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.column
table.column
attributes
Name | Required | Value |
---|---|---|
as | false | string |
auto_increment | false | bool |
comment | false | string |
default | false | Column default value can be one of:
|
null | false | bool |
type | true | Column type can be one of:
|
unsigned | false | bool |
table.column
blocks
table.column.as
table.column.as
attributes
Name | Required | Value |
---|---|---|
expr | true | string |
type | false |
|
table.column.as
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.column
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [as (attribute), as (block)] |
table.foreign_key
table.foreign_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Foreign key columns can be one of:
|
comment | false | string |
on_delete | false |
|
on_update | false |
|
ref_columns | true | Foreign key reference columns can be one of:
|
table.foreign_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
table.index
table.index
attributes
Name | Required | Value |
---|---|---|
columns | false | Index columns can be one of:
|
comment | false | string |
unique | false | bool |
where | false | string |
table.index
blocks
table.index.on
table.index.on
attributes
Name | Required | Value |
---|---|---|
column | false | Index columns can be one of:
|
desc | false | bool |
expr | false | string |
table.index.on
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [column, expr] |
table.index
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [columns, on] |
One of required sets | [columns, on] |
table.primary_key
table.primary_key
attributes
Name | Required | Value |
---|---|---|
columns | true | Primary key columns can be one of:
|
comment | false | string |
table.primary_key
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
trigger
The trigger
block describes a trigger on a table in a database schema.
trigger "trigger_orders_audit" {
on = table.orders
...
}
Attributes
Name | Required | Value |
---|---|---|
as | true | string |
for | false |
|
foreach | false |
|
on | true | Trigger on can be one of: |
when | false | string |
Blocks
trigger.after
trigger.after
attributes
Name | Required | Value |
---|---|---|
delete | false | bool |
insert | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.after
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [insert, delete, update, update_of] |
One of required sets | [insert, delete, update, update_of] |
trigger.before
trigger.before
attributes
Name | Required | Value |
---|---|---|
delete | false | bool |
insert | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.before
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [insert, delete, update, update_of] |
One of required sets | [insert, delete, update, update_of] |
trigger.instead_of
trigger.instead_of
attributes
Name | Required | Value |
---|---|---|
delete | false | bool |
insert | false | bool |
update | false | bool |
update_of | false | Trigger update_of columns can be one of:
|
trigger.instead_of
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | false |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [insert, delete, update, update_of] |
One of required sets | [insert, delete, update, update_of] |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | false |
Repeatable | true |
Allow unknown blocks | false |
Allow unknown attributes | false |
Mutually exclusive sets | [foreach, for] , [before, after, instead_of] |
One of required sets | [before, after, instead_of] |
view
The view
block describes a view in a database schema.
view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}
Attributes
Name | Required | Value |
---|---|---|
as | true | string |
comment | false | string |
depends_on | false | List of object references |
schema | true | Object reference to |
Blocks
view.column
view.column
attributes
Name | Required | Value |
---|---|---|
comment | false | string |
null | false | bool |
type | true | Column type can be one of:
|
view.column
constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |
Constraints
Constraint | Value |
---|---|
Required | false |
Require Name | true |
Allow Qualifier | true |
Repeatable | false |
Allow unknown blocks | false |
Allow unknown attributes | false |