@dbml/cli 5.2.0 → 5.3.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.
Files changed (47) hide show
  1. package/__tests__/db2dbml/mssql/dbml-error.log +39 -6
  2. package/__tests__/db2dbml/mysql/dbml-error.log +10 -1
  3. package/__tests__/db2dbml/oracle/dbml-error.log +91 -0
  4. package/__tests__/db2dbml/oracle/expect-out-files/schema.dbml +419 -0
  5. package/__tests__/db2dbml/oracle/options.json +8 -0
  6. package/__tests__/db2dbml/oracle/out-files/schema.dbml +419 -0
  7. package/__tests__/db2dbml/oracle/schema.sql +529 -0
  8. package/__tests__/db2dbml/oracle/stdout.txt +1 -0
  9. package/__tests__/db2dbml/postgres/dbml-error.log +25 -4
  10. package/__tests__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +1 -1
  11. package/__tests__/dbml2sql/filename --oracle --out-file/out-files/schema.sql +1 -1
  12. package/__tests__/dbml2sql/filename --out-file/out-files/schema.sql +1 -1
  13. package/__tests__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +1 -1
  14. package/__tests__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +1 -1
  15. package/__tests__/dbml2sql/filenames --oracle --out-file/out-files/schema.sql +1 -1
  16. package/__tests__/dbml2sql/filenames --out-file/out-files/schema.sql +1 -1
  17. package/__tests__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +1 -1
  18. package/__tests__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +1 -1
  19. package/__tests__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +1 -1
  20. package/__tests__/dbml2sql/multiple_schema_oracle/out-files/multiple_schema.out.sql +1 -1
  21. package/__tests__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +1 -1
  22. package/__tests__/dbml2sql/syntax-error/dbml-error.log +9 -3
  23. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/dbml-error.log +51 -0
  24. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/out-files/schema.dbml +0 -0
  25. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/dbml-error.log +51 -0
  26. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/out-files/schema.dbml +0 -0
  27. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/dbml-error.log +51 -0
  28. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/out-files/schema.dbml +0 -0
  29. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/dbml-error.log +51 -0
  30. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/out-files/schema.dbml +0 -0
  31. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/dbml-error.log +51 -0
  32. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/out-files/schema.dbml +0 -0
  33. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/dbml-error.log +27 -0
  34. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/out-files/schema.dbml +0 -0
  35. package/__tests__/sql2dbml/filename --oracle --out-file/dbml-error.log +0 -0
  36. package/__tests__/sql2dbml/filename --oracle --out-file/out-files/schema.dbml +83 -0
  37. package/__tests__/sql2dbml/syntax-error/dbml-error.log +45 -3
  38. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +45 -3
  39. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +45 -3
  40. package/lib/cli/index.js +1 -0
  41. package/lib/cli/utils.js +1 -1
  42. package/package.json +4 -4
  43. package/src/cli/index.js +1 -0
  44. package/src/cli/utils.js +1 -1
  45. package/__tests__/db2dbml/mssql/out-files/schema.dbml +0 -219
  46. package/__tests__/db2dbml/mysql/out-files/schema.dbml +0 -188
  47. package/__tests__/db2dbml/postgres/out-files/schema.dbml +0 -184
@@ -0,0 +1,419 @@
1
+ Table "PK_SIMPLE" {
2
+ "ID" number [pk, not null, increment]
3
+ "NAME" varchar2(100) [not null]
4
+ }
5
+
6
+ Table "SELF_REF_FK" {
7
+ "ID" number [pk, not null, increment]
8
+ "PARENT_ID" number
9
+ "NAME" varchar2(100) [not null]
10
+ }
11
+
12
+ Table "FK_PARENT" {
13
+ "ID" number [pk, not null, increment]
14
+ "NAME" varchar2(100) [not null]
15
+ }
16
+
17
+ Table "FK_CHILD" {
18
+ "ID" number [pk, not null, increment]
19
+ "PARENT_ID" number [not null]
20
+ "DESCRIPTION" varchar2(200)
21
+ }
22
+
23
+ Table "CHECK_CONSTRAINTS" {
24
+ "ID" number [pk, not null, increment]
25
+ "AGE" number [not null, check: `age > 0`]
26
+ "SALARY" "number(10, 2)" [not null, check: `salary BETWEEN 0 AND 1000000`]
27
+ "STATUS" varchar2(20) [not null, check: `status IN ('active', 'inactive', 'pending')`]
28
+ "START_DATE" date
29
+ "END_DATE" date
30
+
31
+ Checks {
32
+ `start_date <= end_date` [name: 'CHK_DATE_RANGE']
33
+ }
34
+ }
35
+
36
+ Table "DEFAULT_VALUES" {
37
+ "ID" number [pk, not null, increment]
38
+ "STR_DEFAULT" varchar2(50) [default: 'default_string']
39
+ "NUM_DEFAULT" number [default: 42]
40
+ "DECIMAL_DEFAULT" "number(10, 2)" [default: 99.99]
41
+ "DATE_DEFAULT" date [default: `SYSDATE`]
42
+ "TIMESTAMP_DEFAULT" timestamp(6) [default: `SYSTIMESTAMP`]
43
+ "CHAR_DEFAULT" char(10) [default: 'fixed']
44
+ }
45
+
46
+ Table "NOT_NULL_COLS" {
47
+ "ID" number [pk, not null, increment]
48
+ "REQUIRED_STR" varchar2(100) [not null]
49
+ "REQUIRED_NUM" number [not null]
50
+ "REQUIRED_DATE" date [not null]
51
+ }
52
+
53
+ Table "NULLABLE_COLS" {
54
+ "ID" number [pk, not null, increment]
55
+ "OPTIONAL_STR" varchar2(100)
56
+ "OPTIONAL_NUM" number
57
+ "OPTIONAL_DATE" date
58
+ }
59
+
60
+ Table "AUTOINCREMENT_TABLE" {
61
+ "ID" number [pk, not null, increment]
62
+ "NAME" varchar2(100) [not null]
63
+ }
64
+
65
+ Table "UNIQUE_COLS" {
66
+ "ID" number [pk, not null, increment]
67
+ "EMAIL" varchar2(100) [unique, not null]
68
+ "USERNAME" varchar2(50) [unique, not null]
69
+ }
70
+
71
+ Table "COMPOSITE_PK" {
72
+ "REGION_ID" number [not null]
73
+ "PRODUCT_ID" number [not null]
74
+ "QUANTITY" number [default: 0]
75
+ "PRICE" "number(10, 2)"
76
+
77
+ Indexes {
78
+ (REGION_ID, PRODUCT_ID) [pk, unique, name: "PK_COMPOSITE"]
79
+ }
80
+ }
81
+
82
+ Table "COMPOSITE_SELF_REF" {
83
+ "DEPT_ID" number [not null]
84
+ "EMP_ID" number [not null]
85
+ "PARENT_DEPT_ID" number
86
+ "PARENT_EMP_ID" number
87
+ "NAME" varchar2(100) [not null]
88
+
89
+ Indexes {
90
+ (DEPT_ID, EMP_ID) [pk, unique, name: "PK_COMPOSITE_SELF_REF"]
91
+ }
92
+ }
93
+
94
+ Table "COMPOSITE_UNIQUE" {
95
+ "ID" number [pk, not null, increment]
96
+ "FIRST_NAME" varchar2(50) [not null]
97
+ "LAST_NAME" varchar2(50) [not null]
98
+ "EMAIL" varchar2(100)
99
+
100
+ Indexes {
101
+ (FIRST_NAME, LAST_NAME) [unique, name: "UQ_FULL_NAME"]
102
+ }
103
+ }
104
+
105
+ Table "FUNCTIONAL_INDEX_TABLE" {
106
+ "ID" number [pk, not null, increment]
107
+ "FULL_NAME" varchar2(100) [not null]
108
+ "EMAIL" varchar2(100) [not null]
109
+
110
+ Indexes {
111
+ `LOWER("FULL_NAME")` [type: btree, name: "IDX_LOWER_NAME"]
112
+ `UPPER("EMAIL")` [type: btree, name: "IDX_UPPER_EMAIL"]
113
+ }
114
+ }
115
+
116
+ Table "COMPOSITE_INDEX_TABLE" {
117
+ "ID" number [pk, not null, increment]
118
+ "FIRST_NAME" varchar2(50) [not null]
119
+ "LAST_NAME" varchar2(50) [not null]
120
+ "DEPARTMENT" varchar2(50)
121
+
122
+ Indexes {
123
+ (DEPARTMENT, LAST_NAME) [type: btree, name: "IDX_COMPOSITE_DEPT"]
124
+ (FIRST_NAME, LAST_NAME) [type: btree, name: "IDX_COMPOSITE_NAME"]
125
+ }
126
+ }
127
+
128
+ Table "MIXED_INDEX_TABLE" {
129
+ "ID" number [pk, not null, increment]
130
+ "FIRST_NAME" varchar2(50) [not null]
131
+ "LAST_NAME" varchar2(50) [not null]
132
+ "EMAIL" varchar2(100)
133
+
134
+ Indexes {
135
+ (FIRST_NAME, `UPPER("EMAIL")`) [type: btree, name: "IDX_MIXED_EMAIL"]
136
+ (`LOWER("FIRST_NAME")`, LAST_NAME) [type: btree, name: "IDX_MIXED_NAME"]
137
+ }
138
+ }
139
+
140
+ Table "COLUMN_INDEX_TABLE" {
141
+ "ID" number [pk, not null, increment]
142
+ "CATEGORY" varchar2(50)
143
+ "STATUS" varchar2(20)
144
+ "CREATED_AT" date [default: `SYSDATE
145
+ `]
146
+
147
+ Indexes {
148
+ CATEGORY [type: btree, name: "IDX_CATEGORY"]
149
+ CREATED_AT [type: btree, name: "IDX_CREATED_AT"]
150
+ STATUS [type: btree, name: "IDX_STATUS"]
151
+ }
152
+ }
153
+
154
+ Table "ALTER_ADD_PK" {
155
+ "ID" number [pk, not null]
156
+ "NAME" varchar2(100)
157
+ }
158
+
159
+ Table "ALTER_FK_PARENT" {
160
+ "ID" number [pk, not null, increment]
161
+ "NAME" varchar2(100)
162
+ }
163
+
164
+ Table "ALTER_FK_CHILD" {
165
+ "PARENT_ID" number
166
+ "ID" number [pk, not null, increment]
167
+ }
168
+
169
+ Table "ALTER_SELF_REF" {
170
+ "ID" number [pk, not null, increment]
171
+ "PARENT_ID" number
172
+ "NAME" varchar2(100)
173
+ }
174
+
175
+ Table "ALTER_ADD_CHECK" {
176
+ "ID" number [pk, not null, increment]
177
+ "AGE" number [check: `age >= 18`]
178
+ "SALARY" "number(10, 2)" [check: `salary > 0`]
179
+ "STATUS" varchar2(20) [check: `status IN ('A', 'B', 'C')`]
180
+ }
181
+
182
+ Table "ALTER_ADD_UNIQUE" {
183
+ "ID" number [pk, not null, increment]
184
+ "EMAIL" varchar2(100) [unique]
185
+ "CODE" varchar2(20) [unique]
186
+ }
187
+
188
+ Table "ALTER_COMPOSITE_PK" {
189
+ "REGION_ID" number [not null]
190
+ "PRODUCT_ID" number [not null]
191
+ "QUANTITY" number
192
+
193
+ Indexes {
194
+ (REGION_ID, PRODUCT_ID) [pk, unique, name: "PK_ALTER_COMPOSITE"]
195
+ }
196
+ }
197
+
198
+ Table "ALTER_COMPOSITE_FK_PARENT" {
199
+ "DEPT_ID" number [not null]
200
+ "EMP_ID" number [not null]
201
+ "NAME" varchar2(100)
202
+
203
+ Indexes {
204
+ (DEPT_ID, EMP_ID) [pk, unique, name: "PK_ALTER_COMP_PARENT"]
205
+ }
206
+ }
207
+
208
+ Table "ALTER_COMPOSITE_FK_CHILD" {
209
+ "ID" number [pk, not null, increment]
210
+ "REF_DEPT_ID" number
211
+ "REF_EMP_ID" number
212
+ }
213
+
214
+ Table "ALTER_COMPOSITE_UNIQUE" {
215
+ "ID" number [pk, not null, increment]
216
+ "FIRST_NAME" varchar2(50)
217
+ "LAST_NAME" varchar2(50)
218
+
219
+ Indexes {
220
+ (FIRST_NAME, LAST_NAME) [unique, name: "UQ_ALTER_FULLNAME"]
221
+ }
222
+ }
223
+
224
+ Table "ALTER_ADD_COLUMN" {
225
+ "ID" number [pk, not null, increment]
226
+ "NAME" varchar2(100)
227
+ "NEW_COL" varchar2(50)
228
+ "ANOTHER_COL" number [default: 0]
229
+ "DATE_COL" date [default: `SYSDATE`]
230
+ }
231
+
232
+ Table "IDX_BTREE_TABLE" {
233
+ "ID" number [pk, not null, increment]
234
+ "CODE" varchar2(20)
235
+ "CATEGORY" varchar2(50)
236
+
237
+ Indexes {
238
+ CODE [type: btree, name: "IDX_BTREE_CODE"]
239
+ }
240
+ }
241
+
242
+ Table "IDX_BITMAP_TABLE" {
243
+ "ID" number [pk, not null, increment]
244
+ "GENDER" varchar2(10)
245
+ "STATUS" varchar2(20)
246
+
247
+ Indexes {
248
+ GENDER [type: bitmap, name: "IDX_BITMAP_GENDER"]
249
+ STATUS [type: bitmap, name: "IDX_BITMAP_STATUS"]
250
+ }
251
+ }
252
+
253
+ Table "IDX_UNIQUE_TABLE" {
254
+ "ID" number [pk, not null, increment]
255
+ "EMAIL" varchar2(100)
256
+ "SSN" varchar2(20)
257
+
258
+ Indexes {
259
+ EMAIL [type: btree, unique, name: "IDX_UNIQUE_EMAIL"]
260
+ SSN [type: btree, unique, name: "IDX_UNIQUE_SSN"]
261
+ }
262
+ }
263
+
264
+ Table "IDX_COMPOSITE_ONLY" {
265
+ "ID" number [pk, not null, increment]
266
+ "COL1" varchar2(50)
267
+ "COL2" varchar2(50)
268
+ "COL3" varchar2(50)
269
+
270
+ Indexes {
271
+ (COL1, COL2) [type: btree, name: "IDX_COMP_12"]
272
+ (COL1, COL2, COL3) [type: btree, name: "IDX_COMP_123"]
273
+ (COL2, COL3) [type: btree, name: "IDX_COMP_23"]
274
+ }
275
+ }
276
+
277
+ Table "IDX_FUNCTIONAL_ONLY" {
278
+ "ID" number [pk, not null, increment]
279
+ "FULL_NAME" varchar2(100)
280
+ "DESCRIPTION" varchar2(500)
281
+
282
+ Indexes {
283
+ `LOWER("FULL_NAME")` [type: btree, name: "IDX_FUNC_LOWER_NAME"]
284
+ `SUBSTR("DESCRIPTION",1,100)` [type: btree, name: "IDX_FUNC_SUBSTR"]
285
+ }
286
+ }
287
+
288
+ Table "REF_SIMPLE_PARENT" {
289
+ "ID" number [pk, not null, increment]
290
+ "NAME" varchar2(100)
291
+ }
292
+
293
+ Table "REF_SIMPLE_CHILD" {
294
+ "ID" number [pk, not null, increment]
295
+ "PARENT_ID" number
296
+ }
297
+
298
+ Table "REF_COMPOSITE_PARENT" {
299
+ "KEY1" number [not null]
300
+ "KEY2" number [not null]
301
+ "DATA" varchar2(100)
302
+
303
+ Indexes {
304
+ (KEY1, KEY2) [pk, unique, name: "PK_REF_COMP_PARENT"]
305
+ }
306
+ }
307
+
308
+ Table "REF_COMPOSITE_CHILD" {
309
+ "ID" number [pk, not null, increment]
310
+ "FK1" number
311
+ "FK2" number
312
+ }
313
+
314
+ Table "ORACLE_DATA_TYPES" {
315
+ "CLOB_COL" clob
316
+ "NCLOB_COL" nclob
317
+ "BLOB_COL" blob
318
+ "RAW_COL" raw(100)
319
+ "ROWID_COL" rowid
320
+ "ID" number [pk, not null, increment]
321
+ "CHAR_COL" char(10)
322
+ "VARCHAR2_COL" varchar2(100)
323
+ "NCHAR_COL" nchar(20)
324
+ "NVARCHAR2_COL" nvarchar2(200)
325
+ "NUMBER_COL" number
326
+ "NUMBER_PRECISION" "number(10, 0)"
327
+ "NUMBER_SCALE" "number(10, 2)"
328
+ "BINARY_FLOAT_COL" binary_float
329
+ "BINARY_DOUBLE_COL" binary_double
330
+ "DATE_COL" date
331
+ "TIMESTAMP_COL" timestamp(6)
332
+ "TIMESTAMP_TZ" "timestamp(6) with time zone"
333
+ "TIMESTAMP_LTZ" "timestamp(6) with local time zone"
334
+ "INTERVAL_YM" "interval year(2) to month"
335
+ "INTERVAL_DS" "interval day(2) to second(6)"
336
+ }
337
+
338
+ Table "TABLE_WITH_COMMENTS" {
339
+ "ID" number [pk, not null, increment, note: 'Unique
340
+ identifier']
341
+ "NAME" varchar2(100) [not null, note: '!@#$%^&*()[]"Item name - required field']
342
+ "DESCRIPTION" varchar2(500) [note: 'Optional description of the item']
343
+ Note: '''This table\'\'
344
+ stores items with descriptions'''
345
+ }
346
+
347
+ Table "ALTER_COMP_SELF_REF" {
348
+ "DEPT_ID" number [not null]
349
+ "EMP_ID" number [not null]
350
+ "PARENT_DEPT_ID" number
351
+ "PARENT_EMP_ID" number
352
+ "NAME" varchar2(100)
353
+
354
+ Indexes {
355
+ (DEPT_ID, EMP_ID) [pk, unique, name: "PK_ALTER_COMP_SELF"]
356
+ }
357
+ }
358
+
359
+ Table "SPECIAL_DATA_TYPES" {
360
+ "ID" number [pk, not null, increment]
361
+ "TS_DEFAULT" timestamp(6)
362
+ "TS_0" timestamp(0)
363
+ "TS_3" timestamp(3)
364
+ "TS_6" timestamp(6)
365
+ "TS_9" timestamp(9)
366
+ "TS_TZ_DEFAULT" "timestamp(6) with time zone"
367
+ "TS_TZ_0" "timestamp(0) with time zone"
368
+ "TS_TZ_3" "timestamp(3) with time zone"
369
+ "TS_TZ_6" "timestamp(6) with time zone"
370
+ "TS_TZ_9" "timestamp(9) with time zone"
371
+ "TS_LTZ_DEFAULT" "timestamp(6) with local time zone"
372
+ "TS_LTZ_0" "timestamp(0) with local time zone"
373
+ "TS_LTZ_3" "timestamp(3) with local time zone"
374
+ "TS_LTZ_6" "timestamp(6) with local time zone"
375
+ "TS_LTZ_9" "timestamp(9) with local time zone"
376
+ "IYM_DEFAULT" "interval year(2) to month"
377
+ "IYM_2" "interval year(2) to month"
378
+ "IYM_4" "interval year(4) to month"
379
+ "IYM_9" "interval year(9) to month"
380
+ "IDS_DEFAULT" "interval day(2) to second(6)"
381
+ "IDS_DAY_4" "interval day(4) to second(6)"
382
+ "IDS_SEC_3" "interval day(2) to second(3)"
383
+ "IDS_BOTH" "interval day(5) to second(4)"
384
+ "FLOAT_DEFAULT" float(126)
385
+ "FLOAT_1" float(1)
386
+ "FLOAT_63" float(63)
387
+ "FLOAT_126" float(126)
388
+ "NUM_DEFAULT" number
389
+ "NUM_P" "number(5, 0)"
390
+ "NUM_PS" "number(10, 2)"
391
+ "NUM_P_NEG_S" "number(10, -2)"
392
+ "CHAR_DEFAULT" char(1)
393
+ "CHAR_SIZED" char(50)
394
+ "VARCHAR2_SIZED" varchar2(255)
395
+ "NCHAR_DEFAULT" nchar(2)
396
+ "NCHAR_SIZED" nchar(100)
397
+ "NVARCHAR2_SIZED" nvarchar2(510)
398
+ "RAW_SIZED" raw(200)
399
+ "UROWID_DEFAULT" urowid(4000)
400
+ "UROWID_SIZED" urowid(100)
401
+ }
402
+
403
+ Ref "FK_SELF_REF":"SELF_REF_FK"."ID" < "SELF_REF_FK"."PARENT_ID" [delete: set null]
404
+
405
+ Ref "FK_CHILD_PARENT":"FK_PARENT"."ID" < "FK_CHILD"."PARENT_ID" [delete: cascade]
406
+
407
+ Ref "FK_COMPOSITE_SELF":"COMPOSITE_SELF_REF".("DEPT_ID", "EMP_ID") < "COMPOSITE_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID") [delete: set null]
408
+
409
+ Ref "FK_ALTER_PARENT":"ALTER_FK_PARENT"."ID" < "ALTER_FK_CHILD"."PARENT_ID" [delete: cascade]
410
+
411
+ Ref "FK_ALTER_SELF":"ALTER_SELF_REF"."ID" < "ALTER_SELF_REF"."PARENT_ID" [delete: set null]
412
+
413
+ Ref "FK_ALTER_COMPOSITE":"ALTER_COMPOSITE_FK_PARENT".("DEPT_ID", "EMP_ID") < "ALTER_COMPOSITE_FK_CHILD".("REF_DEPT_ID", "REF_EMP_ID")
414
+
415
+ Ref "FK_REF_SIMPLE":"REF_SIMPLE_PARENT"."ID" < "REF_SIMPLE_CHILD"."PARENT_ID"
416
+
417
+ Ref "FK_REF_COMPOSITE":"REF_COMPOSITE_PARENT".("KEY1", "KEY2") < "REF_COMPOSITE_CHILD".("FK1", "FK2")
418
+
419
+ Ref "FK_ALTER_COMP_SELF":"ALTER_COMP_SELF_REF".("DEPT_ID", "EMP_ID") < "ALTER_COMP_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID")