* Revert "v7.12.0 release" This reverts commit 073723cb4d41187f839fbb46565d109293fa22d7. * set version to v7.13.0-SNAPSHOT * update samples * update doc
PostgreSQL Schema Codegen
Main goal of this generator is to provide PostgreSQL database DDL script that drops and then creates database objects for the given OpenAPI application
Requirements
- PostgreSQL Server v9.4 or newer
OpenAPI Data Type to PostgreSQL data type mapping
| OpenAPI data type | OpenAPI data format | Dependent properties | PostgreSQL data types | Default PostgreSQL data type |
|---|---|---|---|---|
integer |
int32 |
minimum / maximum / minimumExclusive / maximumExclusive |
SMALLINT / INT / BIGINT |
INT |
integer |
int64 |
minimum / maximum / minimumExclusive / maximumExclusive |
SMALLINT / INT / BIGINT |
BIGINT |
boolean |
BOOLEAN |
BOOLEAN |
||
number |
float |
DECIMAL |
DECIMAL |
|
number |
double |
DECIMAL |
DECIMAL |
|
string |
minLength / maxLength |
VARCHAR / TEXT |
TEXT |
|
string |
byte |
BYTEA |
BYTEA |
|
string |
binary |
BYTEA |
BYTEA |
|
file |
BYTEA |
BYTEA |
||
string |
date |
DATE |
DATE |
|
string |
date-time |
TIMESTAMP |
TIMESTAMP |
|
string |
enum |
ENUM(via separate ENUM data type) |
ENUM(via separate ENUM data type) |
|
array |
JSON / JSONB / TEXT |
JSON |
||
object |
JSON / JSONB / TEXT |
JSON |
||
\Model\User (referenced definition) |
TEXT |
TEXT |
How to use
Produced files:
-
postgresql_schema.sqlthat contains:-
DROP ...SQL statements for dropping every table and data type generated by this script; -
CREATE ...SQL statements for creating every table and data types for them (forENUMtypes).
Note: For safety reasons
DROP ...SQL statements are commented out by default. Uncomment them before use.Note:
ENUMdata types are implemented by creating separate data types first using commandCREATE TYPE(one data type for eachENUMcolumn). Then created data type is used as data type for table column. -
-
postgresql_schema_oauth2.sqlthat contains table creation commands for Oauth2-related tables. -
Model folder contains files with sample SQL queries for each table. Copy-paste them, edit and use.
Note: Important! Some of SQLs(INSERT/UPDATE) contains question marks(?) which are parameter placeholders. You need to bind values to these params to execute query.