2021-08-28 21:12:08 +02:00
|
|
|
$GENERATED_SQL_COMMENT
|
|
|
|
|
2021-08-02 16:52:31 +02:00
|
|
|
#for $table in $tables
|
|
|
|
CREATE TABLE ${table.name}_t (
|
|
|
|
id serial not null primary key
|
|
|
|
#for $column in $table.columns
|
|
|
|
,$column.name $column.sqltype #slurp
|
|
|
|
#if (('notnull' in $column) and $column.notnull)
|
|
|
|
not null #slurp
|
|
|
|
#end if
|
|
|
|
#if (('primarykey' in $column) and $column.primarykey)
|
|
|
|
primary key #slurp
|
|
|
|
#end if
|
|
|
|
#if (('foreignkey' in $column) and $column.foreignkey)
|
|
|
|
references ${column.name}_t (id) #slurp
|
|
|
|
#end if
|
2021-09-10 11:59:08 +02:00
|
|
|
#if (('unique' in $column) and $column.unique)
|
|
|
|
unique #slurp
|
|
|
|
#end if
|
2021-08-02 16:52:31 +02:00
|
|
|
#if ('default' in $column)
|
|
|
|
default $column.default #slurp
|
|
|
|
#end if
|
|
|
|
|
|
|
|
#end for
|
|
|
|
#if ('tableConstraints' in $table)
|
|
|
|
#for $tableConstraint in $table.tableConstraints
|
|
|
|
,$tableConstraint
|
|
|
|
#end for
|
|
|
|
#end if
|
|
|
|
);
|
|
|
|
|
2021-09-10 11:59:08 +02:00
|
|
|
GRANT SELECT, INSERT#slurp
|
|
|
|
#if (('immutable' not in $table) or (not $table.immutable))
|
|
|
|
, UPDATE#slurp
|
|
|
|
#end if
|
|
|
|
ON ${table.name}_t TO hv2;
|
|
|
|
GRANT SELECT, UPDATE ON ${table.name}_t_id_seq TO hv2;
|
|
|
|
|
2021-08-02 16:52:31 +02:00
|
|
|
#end for
|
|
|
|
|
|
|
|
|
2021-09-10 11:59:08 +02:00
|
|
|
|