@apso/cli 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/generate.js +3 -2
- package/dist/commands/import/supabase.js +31 -6
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +31 -1
- package/dist/commands/mcp/serve.js +23 -2
- package/dist/lib/apsorc-parser.d.ts +13 -1
- package/dist/lib/apsorc-parser.js +47 -4
- package/dist/lib/ddl/catalog.js +5 -2
- package/dist/lib/ddl/change.js +13 -2
- package/dist/lib/ddl/index.d.ts +62 -3
- package/dist/lib/ddl/index.js +211 -40
- package/dist/lib/generators/go.js +17 -3
- package/dist/lib/generators/python.js +17 -3
- package/dist/lib/generators/typescript.d.ts +2 -1
- package/dist/lib/generators/typescript.js +87 -13
- package/dist/lib/import/copy-data.js +4 -0
- package/dist/lib/import/introspect.d.ts +40 -0
- package/dist/lib/import/introspect.js +137 -49
- package/dist/lib/import/pg-to-apsorc.d.ts +62 -0
- package/dist/lib/import/pg-to-apsorc.js +248 -37
- package/dist/lib/import/types.d.ts +48 -3
- package/dist/lib/migrate/sandbox.js +23 -6
- package/dist/lib/migrate/snapshot.d.ts +5 -0
- package/dist/lib/plan/index.d.ts +4 -1
- package/dist/lib/plan/index.js +9 -3
- package/dist/lib/templates/entities/entity-col-array.eta +2 -1
- package/dist/lib/templates/entities/entity-col-bigint.eta +2 -2
- package/dist/lib/templates/entities/entity-col-bigserial.eta +2 -2
- package/dist/lib/templates/entities/entity-col-boolean.eta +1 -1
- package/dist/lib/templates/entities/entity-col-bytea.eta +2 -2
- package/dist/lib/templates/entities/entity-col-char.eta +4 -3
- package/dist/lib/templates/entities/entity-col-date.eta +6 -2
- package/dist/lib/templates/entities/entity-col-datetime.eta +8 -1
- package/dist/lib/templates/entities/entity-col-decimal.eta +2 -2
- package/dist/lib/templates/entities/entity-col-double.eta +2 -2
- package/dist/lib/templates/entities/entity-col-float.eta +1 -1
- package/dist/lib/templates/entities/entity-col-geography.eta +1 -1
- package/dist/lib/templates/entities/entity-col-geometry.eta +1 -1
- package/dist/lib/templates/entities/entity-col-geometrycollection.eta +1 -1
- package/dist/lib/templates/entities/entity-col-inet.eta +2 -2
- package/dist/lib/templates/entities/entity-col-int4range.eta +1 -1
- package/dist/lib/templates/entities/entity-col-integer.eta +2 -2
- package/dist/lib/templates/entities/entity-col-interval.eta +2 -2
- package/dist/lib/templates/entities/entity-col-json-plain.eta +1 -1
- package/dist/lib/templates/entities/entity-col-json.eta +1 -1
- package/dist/lib/templates/entities/entity-col-jsonb.eta +1 -1
- package/dist/lib/templates/entities/entity-col-linestring.eta +1 -1
- package/dist/lib/templates/entities/entity-col-money.eta +2 -2
- package/dist/lib/templates/entities/entity-col-multilinestring.eta +1 -1
- package/dist/lib/templates/entities/entity-col-multipoint.eta +1 -1
- package/dist/lib/templates/entities/entity-col-multipolygon.eta +1 -1
- package/dist/lib/templates/entities/entity-col-numeric.eta +2 -2
- package/dist/lib/templates/entities/entity-col-point.eta +1 -1
- package/dist/lib/templates/entities/entity-col-polygon.eta +1 -1
- package/dist/lib/templates/entities/entity-col-real.eta +2 -2
- package/dist/lib/templates/entities/entity-col-serial.eta +2 -2
- package/dist/lib/templates/entities/entity-col-smallint.eta +2 -2
- package/dist/lib/templates/entities/entity-col-smallserial.eta +2 -2
- package/dist/lib/templates/entities/entity-col-string.eta +2 -2
- package/dist/lib/templates/entities/entity-col-text.eta +4 -3
- package/dist/lib/templates/entities/entity-col-time.eta +2 -2
- package/dist/lib/templates/entities/entity-col-timestamp.eta +8 -1
- package/dist/lib/templates/entities/entity-col-timestamptz.eta +8 -1
- package/dist/lib/templates/entities/entity-col-timetz.eta +2 -2
- package/dist/lib/templates/entities/entity-col-tsvector.eta +2 -2
- package/dist/lib/templates/entities/entity-col-uuid.eta +5 -2
- package/dist/lib/templates/entities/entity-col-varchar.eta +4 -3
- package/dist/lib/templates/entities/entity-col-xml.eta +2 -2
- package/dist/lib/templates/entities/entity.eta +30 -18
- package/dist/lib/templates/go/models/model.eta +3 -3
- package/dist/lib/templates/python/models/model.eta +1 -1
- package/dist/lib/templates/rest/controller-rest.eta +25 -7
- package/dist/lib/templates/rest/dto-rest.eta +2 -2
- package/dist/lib/templates/rest/index-module-rest.eta +10 -0
- package/dist/lib/templates/rest/schema-extras-module.eta +24 -0
- package/dist/lib/types/constraints.d.ts +13 -0
- package/dist/lib/types/entity.d.ts +67 -2
- package/dist/lib/types/entity.js +39 -1
- package/dist/lib/types/field.d.ts +20 -2
- package/dist/lib/types/generator.d.ts +16 -0
- package/dist/lib/types/index.d.ts +1 -1
- package/dist/lib/types/indices.d.ts +21 -0
- package/dist/lib/types/relationship.d.ts +33 -0
- package/dist/lib/types/relationship.js +13 -0
- package/dist/lib/utils/field.d.ts +22 -0
- package/dist/lib/utils/field.js +62 -3
- package/dist/lib/utils/relationships/index.d.ts +1 -1
- package/dist/lib/utils/relationships/index.js +2 -1
- package/dist/lib/utils/relationships/parse.d.ts +11 -0
- package/dist/lib/utils/relationships/parse.js +44 -1
- package/dist/lib/utils/template.d.ts +3 -3
- package/dist/lib/utils/template.js +4 -4
- package/dist/lib/verify/crud-plan.d.ts +2 -0
- package/dist/lib/verify/crud-plan.js +19 -5
- package/dist/lib/verify/index.js +32 -3
- package/npm-shrinkwrap.json +72 -87
- package/oclif.manifest.json +7 -1
- package/package.json +3 -2
|
@@ -17,6 +17,8 @@ const fs = tslib_1.__importStar(require("fs"));
|
|
|
17
17
|
const path = tslib_1.__importStar(require("path"));
|
|
18
18
|
const paths_1 = require("../config/paths");
|
|
19
19
|
const snapshot_1 = require("./snapshot");
|
|
20
|
+
const entity_1 = require("../types/entity");
|
|
21
|
+
const relationship_1 = require("../types/relationship");
|
|
20
22
|
const field_1 = require("../utils/field");
|
|
21
23
|
const casing_1 = require("../utils/casing");
|
|
22
24
|
const relationships_1 = require("../utils/relationships");
|
|
@@ -87,10 +89,16 @@ function buildEntityClasses(entities, relationshipMap = {}) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
if (entityDef.created_at) {
|
|
90
|
-
typeorm.CreateDateColumn(
|
|
92
|
+
typeorm.CreateDateColumn({
|
|
93
|
+
type: (0, entity_1.timestampTypeOf)(entityDef, "created_at"),
|
|
94
|
+
nullable: (0, entity_1.timestampNullableOf)(entityDef, "created_at"),
|
|
95
|
+
})(EntityClass.prototype, "created_at");
|
|
91
96
|
}
|
|
92
97
|
if (entityDef.updated_at) {
|
|
93
|
-
typeorm.UpdateDateColumn(
|
|
98
|
+
typeorm.UpdateDateColumn({
|
|
99
|
+
type: (0, entity_1.timestampTypeOf)(entityDef, "updated_at"),
|
|
100
|
+
nullable: (0, entity_1.timestampNullableOf)(entityDef, "updated_at"),
|
|
101
|
+
})(EntityClass.prototype, "updated_at");
|
|
94
102
|
}
|
|
95
103
|
const fields = entityDef.fields || [];
|
|
96
104
|
for (const field of fields) {
|
|
@@ -108,7 +116,8 @@ function buildEntityClasses(entities, relationshipMap = {}) {
|
|
|
108
116
|
if (field.unique)
|
|
109
117
|
colOpts.unique = true;
|
|
110
118
|
if (field.default !== undefined && field.default !== null) {
|
|
111
|
-
|
|
119
|
+
const sql = (0, field_1.defaultSqlOf)(field);
|
|
120
|
+
colOpts.default = sql === undefined ? field.default : () => sql;
|
|
112
121
|
}
|
|
113
122
|
if (field.type === "enum" && field.values) {
|
|
114
123
|
colOpts.enum = field.values;
|
|
@@ -145,8 +154,8 @@ function buildEntityClasses(entities, relationshipMap = {}) {
|
|
|
145
154
|
if (relationship.nullable !== undefined) {
|
|
146
155
|
relationOptions.nullable = relationship.nullable;
|
|
147
156
|
}
|
|
148
|
-
if (
|
|
149
|
-
relationOptions.onDelete =
|
|
157
|
+
if ((0, relationship_1.onDeleteOf)(relationship)) {
|
|
158
|
+
relationOptions.onDelete = (0, relationship_1.onDeleteOf)(relationship);
|
|
150
159
|
}
|
|
151
160
|
if (relationship.type === "ManyToOne") {
|
|
152
161
|
if (relationship.index) {
|
|
@@ -156,7 +165,9 @@ function buildEntityClasses(entities, relationshipMap = {}) {
|
|
|
156
165
|
? (target) => target[inversePropertyName]
|
|
157
166
|
: undefined;
|
|
158
167
|
typeorm.ManyToOne(() => targetClass, inverseSide, relationOptions)(EntityClass.prototype, relationship.relationshipName);
|
|
159
|
-
typeorm.JoinColumn({
|
|
168
|
+
typeorm.JoinColumn({
|
|
169
|
+
name: relationship.joinColumnName || relationship.camelCasedId,
|
|
170
|
+
})(EntityClass.prototype, relationship.relationshipName);
|
|
160
171
|
}
|
|
161
172
|
if (relationship.type === "OneToMany" && relationship.biDirectional) {
|
|
162
173
|
typeorm.OneToMany(() => targetClass, (target) => target[inversePropertyName])(EntityClass.prototype, relationship.pluralizedRelationshipName);
|
|
@@ -303,6 +314,8 @@ async function runMigrationSandbox(current, projectDir) {
|
|
|
303
314
|
primaryKeyType: e.primaryKeyType,
|
|
304
315
|
created_at: e.created_at,
|
|
305
316
|
updated_at: e.updated_at,
|
|
317
|
+
timestampType: e.timestampType,
|
|
318
|
+
timestampNullable: e.timestampNullable,
|
|
306
319
|
scopeBy: e.scopeBy,
|
|
307
320
|
});
|
|
308
321
|
}),
|
|
@@ -337,6 +350,8 @@ async function runMigrationSandbox(current, projectDir) {
|
|
|
337
350
|
primaryKeyType: se.primaryKeyType,
|
|
338
351
|
created_at: se.created_at,
|
|
339
352
|
updated_at: se.updated_at,
|
|
353
|
+
timestampType: se.timestampType,
|
|
354
|
+
timestampNullable: se.timestampNullable,
|
|
340
355
|
scopeBy: se.scopeBy,
|
|
341
356
|
});
|
|
342
357
|
})
|
|
@@ -435,6 +450,8 @@ function applyMigration(current, projectDir) {
|
|
|
435
450
|
primaryKeyType: e.primaryKeyType,
|
|
436
451
|
created_at: e.created_at,
|
|
437
452
|
updated_at: e.updated_at,
|
|
453
|
+
timestampType: e.timestampType,
|
|
454
|
+
timestampNullable: e.timestampNullable,
|
|
438
455
|
scopeBy: e.scopeBy,
|
|
439
456
|
});
|
|
440
457
|
}),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* The snapshot stores the .apsorc content at the time of last successful migration.
|
|
6
6
|
* Comparing current .apsorc against the snapshot detects whether a migration is needed.
|
|
7
7
|
*/
|
|
8
|
+
import { Entity } from "../types/entity";
|
|
8
9
|
/**
|
|
9
10
|
* Shape of the stored snapshot (mirrors the parsed .apsorc structure)
|
|
10
11
|
*/
|
|
@@ -22,6 +23,8 @@ export interface ApsorcSnapshot {
|
|
|
22
23
|
primaryKeyType?: string;
|
|
23
24
|
created_at?: boolean;
|
|
24
25
|
updated_at?: boolean;
|
|
26
|
+
timestampType?: Entity["timestampType"];
|
|
27
|
+
timestampNullable?: Entity["timestampNullable"];
|
|
25
28
|
scopeBy?: string | string[];
|
|
26
29
|
}>;
|
|
27
30
|
relationships?: Array<{
|
|
@@ -55,6 +58,8 @@ export interface ComparableSchema {
|
|
|
55
58
|
primaryKeyType?: string;
|
|
56
59
|
created_at?: boolean;
|
|
57
60
|
updated_at?: boolean;
|
|
61
|
+
timestampType?: Entity["timestampType"];
|
|
62
|
+
timestampNullable?: Entity["timestampNullable"];
|
|
58
63
|
scopeBy?: string | string[];
|
|
59
64
|
}>;
|
|
60
65
|
relationships?: ApsorcSnapshot["relationships"];
|
package/dist/lib/plan/index.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ interface PlanField {
|
|
|
3
3
|
type: string;
|
|
4
4
|
values?: string[];
|
|
5
5
|
nullable?: boolean;
|
|
6
|
-
|
|
6
|
+
/** A literal, or { sql } for an expression; the plan only asks whether one is set. */
|
|
7
|
+
default?: unknown;
|
|
7
8
|
elementType?: string;
|
|
9
|
+
/** The expression of a stored generated column. */
|
|
10
|
+
generated?: string;
|
|
8
11
|
}
|
|
9
12
|
interface PlanEntity {
|
|
10
13
|
name: string;
|
package/dist/lib/plan/index.js
CHANGED
|
@@ -147,7 +147,8 @@ function planMigration(before, after, previous) {
|
|
|
147
147
|
});
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
// Postgres rebuilds a generated column from its expression: no cast.
|
|
151
|
+
if (!sameType(cur, old) && !cur.generated) {
|
|
151
152
|
questions.push({
|
|
152
153
|
id: `cast:${now.name}.${old.name}`,
|
|
153
154
|
kind: "cast",
|
|
@@ -168,7 +169,10 @@ function planMigration(before, after, previous) {
|
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
if (old.nullable &&
|
|
172
|
+
if (old.nullable &&
|
|
173
|
+
!cur.nullable &&
|
|
174
|
+
cur.default === undefined &&
|
|
175
|
+
!cur.generated) {
|
|
172
176
|
questions.push({
|
|
173
177
|
id: `backfill:${now.name}.${old.name}`,
|
|
174
178
|
kind: "backfill",
|
|
@@ -222,7 +226,9 @@ function planMigration(before, after, previous) {
|
|
|
222
226
|
for (const f of fieldsOf(now)) {
|
|
223
227
|
if (byName(fieldsOf(was), f.name) ||
|
|
224
228
|
f.nullable ||
|
|
225
|
-
f.default !== undefined
|
|
229
|
+
f.default !== undefined ||
|
|
230
|
+
// Postgres computes a generated column for the existing rows.
|
|
231
|
+
f.generated)
|
|
226
232
|
continue;
|
|
227
233
|
const key = `${now.name}.${f.name}`;
|
|
228
234
|
if (claimed.has(key) || pending.has(key))
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
@Column({
|
|
4
4
|
type: "<%= field.elementType || 'text' %>",
|
|
5
5
|
array: true<% if (field.nullable) {%>,
|
|
6
|
-
nullable: true<% }
|
|
6
|
+
nullable: true<% } %><% if (field.defaultSql) { %>,
|
|
7
|
+
default: () => <%~ JSON.stringify(field.defaultSql) %><% } %>
|
|
7
8
|
})
|
|
8
9
|
<% if (field.index ) {%>
|
|
9
10
|
@Index()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "bigint", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "bigint", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "bigint" })
|
|
3
|
+
@Column({ "type": "bigint"<% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
@Generated("increment")
|
|
5
5
|
<% if (field.index ) {%>
|
|
6
6
|
@Index()
|
|
7
7
|
<% } %>
|
|
8
8
|
<% if (field.primary ) {%>
|
|
9
|
-
@PrimaryColumn()
|
|
9
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
10
10
|
<% } %>
|
|
11
11
|
|
|
12
12
|
<%= field.name %>: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@IsOptional({ groups: [CREATE, UPDATE] })
|
|
4
4
|
@IsBoolean({ always: true })
|
|
5
5
|
|
|
6
|
-
@Column({ type: 'boolean', nullable: <%= Boolean(field.nullable) %>, default: <%= field.default === true || String(field.default).toLowerCase() === 'true' %> })
|
|
6
|
+
@Column({ type: 'boolean', nullable: <%= Boolean(field.nullable) %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } else if (!field.noDefault) { %>, default: <%= field.default === true || String(field.default).toLowerCase() === 'true' %><% } %> })
|
|
7
7
|
<% if (field.index ) {%>
|
|
8
8
|
@Index()
|
|
9
9
|
<% } %>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "bytea", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "bytea", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: Buffer;
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
<% if (field.index ) {%>
|
|
8
8
|
@Index()
|
|
9
9
|
<% } %>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<% if (field.primary) { %>
|
|
11
|
+
@PrimaryColumn({ type: "char", length: <%= field.length || 1 %><% if (field.primaryKeyName) { %>, primaryKeyConstraintName: '<%= field.primaryKeyName %>'<% } %> })
|
|
12
|
+
<% } else { %>
|
|
13
|
+
@Column({ type: "char", length: <%= field.length || 1 %>, nullable: <%= Boolean(field.nullable) %><% if (field.unique) {%>, unique: true <% } %><% if (field.default !== null) {%>, default: '<%= field.default %>'<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
13
14
|
<% } %>
|
|
14
15
|
|
|
15
16
|
<%= field.name %>: string;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<% if (field.
|
|
3
|
+
<% if (field.primary) { %>
|
|
4
|
+
@PrimaryColumn({ type: 'date'<% if (field.primaryKeyName) { %>, primaryKeyConstraintName: '<%= field.primaryKeyName %>'<% } %> })
|
|
5
|
+
<% } else { %>
|
|
6
|
+
<% if (field.index) { %>
|
|
5
7
|
@Index()
|
|
6
8
|
<% } %>
|
|
9
|
+
@Column({ type: 'date', nullable: <%= Boolean(field.nullable) %><% if (field.unique) { %>, unique: true<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
10
|
+
<% } %>
|
|
7
11
|
|
|
8
12
|
<%= field.name %>: string;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<% if (field.primary) { %>
|
|
4
|
+
@PrimaryColumn({ type: 'timestamp'<% if (field.primaryKeyName) { %>, primaryKeyConstraintName: '<%= field.primaryKeyName %>'<% } %> })
|
|
5
|
+
<% } else { %>
|
|
6
|
+
<% if (field.index) { %>
|
|
7
|
+
@Index()
|
|
8
|
+
<% } %>
|
|
9
|
+
@Column({ type: 'timestamp', nullable: <%= Boolean(field.nullable) %><% if (field.unique) { %>, unique: true<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
10
|
+
<% } %>
|
|
4
11
|
<%= field.name %>: Date;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "decimal", precision: <%= field.precision || 10 %>, scale: <%= field.scale || 2 %>, nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "decimal", precision: <%= field.precision || 10 %>, scale: <%= field.scale || 2 %>, nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "float8", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "float8", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "decimal", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "decimal", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "inet"<% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.nullable) {%>, nullable: true<% } %> })
|
|
3
|
+
@Column({ "type": "inet"<% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.nullable) {%>, nullable: true<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: string;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
@Index()
|
|
29
29
|
<% } %>
|
|
30
30
|
<% if (field.primary ) {%>
|
|
31
|
-
@PrimaryColumn()
|
|
31
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
32
32
|
<% } %>
|
|
33
33
|
|
|
34
34
|
<%= field.name %>: {lower: number, upper: number, lowerInclusive: boolean, upperInclusive: boolean};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "int", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "int", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: <%= field.dataType %>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "interval", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "interval", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column('json',{ nullable: <%= Boolean(field.nullable) %>
|
|
3
|
+
@Column('json',{ nullable: <%= Boolean(field.nullable) %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column('jsonb', { nullable: <%= Boolean(field.nullable) %> })
|
|
3
|
+
@Column('jsonb', { nullable: <%= Boolean(field.nullable) %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
|
|
5
5
|
<%= field.name %>: JSON;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column('jsonb', { nullable: <%= Boolean(field.nullable) %> })
|
|
3
|
+
@Column('jsonb', { nullable: <%= Boolean(field.nullable) %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
|
|
5
5
|
<%= field.name %>: any;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
@Index()
|
|
32
32
|
<% } %>
|
|
33
33
|
<% if (field.primary ) {%>
|
|
34
|
-
@PrimaryColumn()
|
|
34
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
35
35
|
<% } %>
|
|
36
36
|
|
|
37
37
|
<%= field.name %>: { coordinates: Array<{ x: number, y: number }> };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "money", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "money", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: string;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
@Index()
|
|
39
39
|
<% } %>
|
|
40
40
|
<% if (field.primary ) {%>
|
|
41
|
-
@PrimaryColumn()
|
|
41
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
42
42
|
<% } %>
|
|
43
43
|
|
|
44
44
|
<%= field.name %>: { coordinates: Array<Array<{ x: number, y: number }>> };
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
@Index()
|
|
32
32
|
<% } %>
|
|
33
33
|
<% if (field.primary ) {%>
|
|
34
|
-
@PrimaryColumn()
|
|
34
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
35
35
|
<% } %>
|
|
36
36
|
|
|
37
37
|
<%= field.name %>: { coordinates: Array<{ x: number, y: number }> };
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
@Index()
|
|
45
45
|
<% } %>
|
|
46
46
|
<% if (field.primary ) {%>
|
|
47
|
-
@PrimaryColumn()
|
|
47
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
48
48
|
<% } %>
|
|
49
49
|
|
|
50
50
|
<%= field.name %>: { coordinates: Array<Array<Array<{ x: number, y: number }>>> };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "numeric", precision: <%= field.precision || 10 %>, scale: <%= field.scale || 2 %>, nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "numeric", precision: <%= field.precision || 10 %>, scale: <%= field.scale || 2 %>, nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: number;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
@Index()
|
|
39
39
|
<% } %>
|
|
40
40
|
<% if (field.primary ) {%>
|
|
41
|
-
@PrimaryColumn()
|
|
41
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
42
42
|
<% } %>
|
|
43
43
|
|
|
44
44
|
<%= field.name %>: { coordinates: Array<Array<{ x: number, y: number }>> };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "real", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "real", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "int" })
|
|
3
|
+
@Column({ "type": "int"<% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
@Generated("increment")
|
|
5
5
|
<% if (field.index ) {%>
|
|
6
6
|
@Index()
|
|
7
7
|
<% } %>
|
|
8
8
|
<% if (field.primary ) {%>
|
|
9
|
-
@PrimaryColumn()
|
|
9
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
10
10
|
<% } %>
|
|
11
11
|
|
|
12
12
|
<%= field.name %>: number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "smallint", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "smallint", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "smallint" })
|
|
3
|
+
@Column({ "type": "smallint"<% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
@Generated("increment")
|
|
5
5
|
<% if (field.index ) {%>
|
|
6
6
|
@Index()
|
|
7
7
|
<% } %>
|
|
8
8
|
<% if (field.primary ) {%>
|
|
9
|
-
@PrimaryColumn()
|
|
9
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
10
10
|
<% } %>
|
|
11
11
|
|
|
12
12
|
<%= field.name %>: number;
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
<% if (field.index ) {%>
|
|
16
16
|
@Index()
|
|
17
17
|
<% } %>
|
|
18
|
-
@Column({ type: "text", nullable: <%= Boolean(field.nullable) %><% if (field.unique) {%>, unique: true <% } %><% if (field.default !== null) {%>, default: '<%= field.default %>'<% } %>
|
|
18
|
+
@Column({ type: "text", nullable: <%= Boolean(field.nullable) %><% if (field.unique) {%>, unique: true <% } %><% if (field.default !== null) {%>, default: '<%= field.default %>'<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
19
19
|
<% if (field.primary ) {%>
|
|
20
|
-
@PrimaryColumn()
|
|
20
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
21
21
|
<% } %>
|
|
22
22
|
|
|
23
23
|
<%= field.name %>: <%= field.dataType %>;
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
<% if (field.index ) {%>
|
|
16
16
|
@Index()
|
|
17
17
|
<% } %>
|
|
18
|
-
|
|
19
|
-
<% if (field.
|
|
20
|
-
|
|
18
|
+
<% if (field.primary) { %>
|
|
19
|
+
@PrimaryColumn({ type: "text"<% if (field.primaryKeyName) { %>, primaryKeyConstraintName: '<%= field.primaryKeyName %>'<% } %> })
|
|
20
|
+
<% } else { %>
|
|
21
|
+
@Column({ type: "text", nullable: <%= Boolean(field.nullable) %><% if (field.unique) {%>, unique: true <% } %><% if (field.default !== null) {%>, default: '<%= field.default %>'<% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
21
22
|
<% } %>
|
|
22
23
|
|
|
23
24
|
<%= field.name %>: <%= field.dataType %>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% const {field} = it; %>
|
|
2
2
|
|
|
3
|
-
@Column({ "type": "time", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %> })
|
|
3
|
+
@Column({ "type": "time", nullable: <%= Boolean(field.nullable) %><% if (field.default !== null) {%>, default: <%= field.default %><% } %><% if (field.defaultSql) { %>, default: () => <%~ JSON.stringify(field.defaultSql) %><% } %> })
|
|
4
4
|
<% if (field.index ) {%>
|
|
5
5
|
@Index()
|
|
6
6
|
<% } %>
|
|
7
7
|
<% if (field.primary ) {%>
|
|
8
|
-
@PrimaryColumn()
|
|
8
|
+
@PrimaryColumn(<% if (field.primaryKeyName) { %>{ primaryKeyConstraintName: '<%= field.primaryKeyName %>' }<% } %>)
|
|
9
9
|
<% } %>
|
|
10
10
|
|
|
11
11
|
<%= field.name %>: string;
|