jsonschema2ddl
Version:
Convert JSON Schema to DDL
55 lines (51 loc) • 1.13 kB
text/typescript
export const POSTGRES_TYPES: Record<string, string> = {
"boolean": "bool",
"number": "float",
"string": "varchar({})",
"enum": "text",
"integer": "bigint",
"date-time": "timestamp",
"timestamp": "timestamp",
"timestampz": "timestamptz",
"date": "date",
"link": "integer",
"array": "json",
"object": "json",
"id": "serial",
}
export const REDSHIFT_TYPES: Record<string, string> = {
...POSTGRES_TYPES,
"array": "super",
"object": "super",
"id": "int identity(1, 1) not null",
}
export const COLUMNS_TYPES: Record<string, Record<string, string>> = {
"postgres": POSTGRES_TYPES,
"redshift": REDSHIFT_TYPES,
}
export const FK_TYPES: Record<string, string> = {
"serial": "bigint",
"int identity(1, 1) not null": "bigint",
}
export const COLUMNS_TYPES_PREFERENCE: Record<string, number> = {
"null": -1,
"boolean": 0,
"bool": 0,
"enum": 1,
"link": 2,
"integer": 3,
"bigint": 4,
"number": 5,
"float": 5,
"date": 5,
"date-time": 6,
"timestamp": 6,
"timestamptz": 6,
"array": 7,
"text": 8,
"string": 8,
"object": 9,
"json": 9,
"id": 10,
"serial": 10,
}