@dbml/cli 5.0.0-alpha.0 → 5.0.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/__test__/db2dbml/mssql/out-files/schema.dbml +13 -13
- package/__test__/db2dbml/mysql/out-files/schema.dbml +4 -4
- package/__test__/db2dbml/postgres/out-files/schema.dbml +11 -11
- package/__test__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filename --oracle --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filename --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filenames --oracle --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filenames --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +1 -1
- package/__test__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +1 -1
- package/__test__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +1 -1
- package/__test__/dbml2sql/multiple_schema_oracle/out-files/multiple_schema.out.sql +1 -1
- package/__test__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +1 -1
- package/__test__/dbml2sql/syntax-error/dbml-error.log +3 -0
- package/__test__/sql2dbml/syntax-error/dbml-error.log +3 -0
- package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +3 -0
- package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +3 -0
- package/package.json +4 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Table "dbo"."users" {
|
|
2
2
|
"user_id" int(10) [pk, not null, increment]
|
|
3
3
|
"username" varchar(50) [unique, not null]
|
|
4
|
-
"email" varchar(100) [unique, not null,
|
|
4
|
+
"email" varchar(100) [unique, not null, check: `[email] like '%_@_%._%'`]
|
|
5
5
|
"password_hash" varchar(255) [not null]
|
|
6
6
|
"first_name" varchar(50)
|
|
7
7
|
"last_name" varchar(50)
|
|
8
8
|
"full_name" varchar(100)
|
|
9
9
|
"full_name_lower" varchar(100)
|
|
10
|
-
"date_of_birth" date [
|
|
10
|
+
"date_of_birth" date [check: `[date_of_birth]<=dateadd(year,(-13),getdate())`]
|
|
11
11
|
"created_at" datetime2 [default: `getdate()`]
|
|
12
12
|
"last_login" datetime2
|
|
13
13
|
"is_active" bit [default: 1]
|
|
@@ -23,8 +23,8 @@ Table "dbo"."products" {
|
|
|
23
23
|
"product_id" int(10) [pk, not null, increment]
|
|
24
24
|
"name" varchar(100) [not null]
|
|
25
25
|
"description" text
|
|
26
|
-
"price" decimal(10,2) [not null,
|
|
27
|
-
"stock_quantity" int(10) [not null,
|
|
26
|
+
"price" decimal(10,2) [not null, check: `[price]>(0)`]
|
|
27
|
+
"stock_quantity" int(10) [not null, check: `[stock_quantity]>=(0)`, default: 0]
|
|
28
28
|
"category" varchar(50)
|
|
29
29
|
"created_at" datetime2 [default: `getdate()`]
|
|
30
30
|
"updated_at" datetime2 [default: `getdate()`]
|
|
@@ -39,8 +39,8 @@ Table "dbo"."orders" {
|
|
|
39
39
|
"order_id" int(10) [pk, not null, increment]
|
|
40
40
|
"user_id" int(10) [not null]
|
|
41
41
|
"order_date" datetime2 [default: `getdate()`]
|
|
42
|
-
"total_amount" decimal(12,2) [not null,
|
|
43
|
-
"status" varchar(20) [
|
|
42
|
+
"total_amount" decimal(12,2) [not null, check: `[total_amount]>(0)`]
|
|
43
|
+
"status" varchar(20) [check: `[status]='cancelled' OR [status]='delivered' OR [status]='shipped' OR [status]='processing' OR [status]='pending'`, default: 'pending']
|
|
44
44
|
"shipping_address" text [not null]
|
|
45
45
|
"billing_address" text [not null]
|
|
46
46
|
|
|
@@ -53,8 +53,8 @@ Table "dbo"."order_items" {
|
|
|
53
53
|
"order_item_id" int(10) [pk, not null, increment]
|
|
54
54
|
"order_id" int(10) [unique, not null]
|
|
55
55
|
"product_id" int(10) [unique, not null]
|
|
56
|
-
"quantity" int(10) [not null,
|
|
57
|
-
"unit_price" decimal(10,2) [not null,
|
|
56
|
+
"quantity" int(10) [not null, check: `[quantity]>(0)`]
|
|
57
|
+
"unit_price" decimal(10,2) [not null, check: `[unit_price]>(0)`]
|
|
58
58
|
|
|
59
59
|
Indexes {
|
|
60
60
|
(order_id, product_id) [type: nonclustered, name: "idx_order_items_order_product"]
|
|
@@ -148,13 +148,13 @@ Table "dbo"."gender_reference" {
|
|
|
148
148
|
Table "dbo"."user_define_data_types" {
|
|
149
149
|
"id" int(10) [pk, not null, increment]
|
|
150
150
|
"name" nvarchar(50)
|
|
151
|
-
"gender" nvarchar(10) [
|
|
151
|
+
"gender" nvarchar(10) [check: `[gender]='Other' OR [gender]='Female' OR [gender]='Male'`]
|
|
152
152
|
"age_start" int(10)
|
|
153
153
|
"age_end" int(10)
|
|
154
154
|
"height" float(53)
|
|
155
155
|
"weight" float(53)
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Checks {
|
|
158
158
|
`[age_start]<=[age_end]` [name: 'chk_age_range']
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -186,7 +186,7 @@ Table "dbo"."AddressInfo" {
|
|
|
186
186
|
"AddressID" uniqueidentifier(16) [not null]
|
|
187
187
|
"AddressFormatID" uniqueidentifier(16) [not null]
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
Checks {
|
|
190
190
|
`([AddressID]='176029FA-D6D3-49E1-A48C-000000000002' OR [AddressID]='176029FA-D6D3-49E1-A48C-000000000001') AND ([AddressFormatID]='176029FA-D6D3-49E1-A48C-000000000002' OR [AddressFormatID]='176029FA-D6D3-49E1-A48C-000000000001')` [name: 'CK_Address_Valid']
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -197,14 +197,14 @@ Table "dbo"."AddressInfo2" {
|
|
|
197
197
|
"A3" uniqueidentifier(16) [not null]
|
|
198
198
|
"A4" uniqueidentifier(16) [not null]
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
Checks {
|
|
201
201
|
`([A1]='333' OR [A1]='2222' OR [A1]='1111') AND ([A2]='2222' OR [A2]='1111') AND ([A3]='1111' OR [A3]='2222') AND ([A4]='3333' OR [A4]='2222')` [name: 'CK_Address_Valid2']
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
Table "dbo"."TestDescriptionTable" {
|
|
206
206
|
"Id" int(10) [note: 'Primary key identifier.']
|
|
207
|
-
"Name" nvarchar(100) [
|
|
207
|
+
"Name" nvarchar(100) [check: `len([Name])>(6)`, note: 'Name of the entity.']
|
|
208
208
|
Note: 'This is the custom comment name on table.'
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -136,11 +136,11 @@ Table "orders" {
|
|
|
136
136
|
Table "products" {
|
|
137
137
|
"id" "int unsigned" [pk, not null, increment]
|
|
138
138
|
"price" decimal(10,2) [not null]
|
|
139
|
-
"quantity" int [not null,
|
|
140
|
-
"total_value" "decimal(10,2) GENERATED ALWAYS AS ((`price` * `quantity`)) STORED" [
|
|
139
|
+
"quantity" int [not null, check: ``quantity` < 10000`]
|
|
140
|
+
"total_value" "decimal(10,2) GENERATED ALWAYS AS ((`price` * `quantity`)) STORED" [check: ``total_value` > 0`]
|
|
141
141
|
"updated_at" "timestamp on update CURRENT_TIMESTAMP" [default: `CURRENT_TIMESTAMP`]
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
Checks {
|
|
144
144
|
`(`price` > 0) and (`price` < 1000000)` [name: 'products_chk_1']
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -174,7 +174,7 @@ Table "users" {
|
|
|
174
174
|
"last_login" timestamp [default: `CURRENT_TIMESTAMP`]
|
|
175
175
|
"is_active" tinyint(1) [default: 1]
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
Checks {
|
|
178
178
|
``created_at` <= `last_login`` [name: 'chk_last_login']
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -37,12 +37,12 @@ Enum "gender_type" {
|
|
|
37
37
|
Table "users" {
|
|
38
38
|
"user_id" int4 [pk, not null, increment]
|
|
39
39
|
"username" varchar(50) [unique, not null]
|
|
40
|
-
"email" varchar(100) [unique, not null,
|
|
40
|
+
"email" varchar(100) [unique, not null, check: `(email)::text ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}$'::text`]
|
|
41
41
|
"password_hash" varchar(255) [not null]
|
|
42
42
|
"first_name" varchar(50)
|
|
43
43
|
"last_name" varchar(50)
|
|
44
44
|
"full_name" varchar(100)
|
|
45
|
-
"date_of_birth" date [
|
|
45
|
+
"date_of_birth" date [check: `date_of_birth <= (CURRENT_DATE - '13 years'::interval)`]
|
|
46
46
|
"created_at" timestamptz [default: `CURRENT_TIMESTAMP`]
|
|
47
47
|
"last_login" timestamptz
|
|
48
48
|
"is_active" bool [default: true]
|
|
@@ -58,14 +58,14 @@ Table "products" {
|
|
|
58
58
|
"product_id" int4 [pk, not null, increment]
|
|
59
59
|
"name" varchar(100) [not null]
|
|
60
60
|
"description" text
|
|
61
|
-
"price" numeric(10,2) [not null,
|
|
62
|
-
"stock_quantity" int4 [not null,
|
|
61
|
+
"price" numeric(10,2) [not null, check: `price > (0)::numeric`]
|
|
62
|
+
"stock_quantity" int4 [not null, check: `stock_quantity >= 0`, default: 0]
|
|
63
63
|
"category" varchar(50)
|
|
64
64
|
"created_at" timestamptz [default: `CURRENT_TIMESTAMP`]
|
|
65
65
|
"updated_at" timestamptz [default: `CURRENT_TIMESTAMP`]
|
|
66
66
|
"is_available" bool [default: true]
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Checks {
|
|
69
69
|
`created_at <= updated_at` [name: 'chk_created_at']
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -78,8 +78,8 @@ Table "orders" {
|
|
|
78
78
|
"order_id" int4 [pk, not null, increment]
|
|
79
79
|
"user_id" int4 [not null]
|
|
80
80
|
"order_date" timestamptz [default: `CURRENT_TIMESTAMP`]
|
|
81
|
-
"total_amount" numeric(12,2) [not null,
|
|
82
|
-
"status" varchar(20) [
|
|
81
|
+
"total_amount" numeric(12,2) [not null, check: `total_amount > (0)::numeric`]
|
|
82
|
+
"status" varchar(20) [check: `(status)::text = ANY ((ARRAY['pending'::character varying, 'processing'::character varying, 'shipped'::character varying, 'delivered'::character varying, 'cancelled'::character varying])::text[])`, default: 'pending']
|
|
83
83
|
"shipping_address" text [not null]
|
|
84
84
|
"billing_address" text [not null]
|
|
85
85
|
|
|
@@ -92,8 +92,8 @@ Table "order_items" {
|
|
|
92
92
|
"order_item_id" int4 [pk, not null, increment]
|
|
93
93
|
"order_id" int4 [not null]
|
|
94
94
|
"product_id" int4 [not null]
|
|
95
|
-
"quantity" int4 [not null,
|
|
96
|
-
"unit_price" numeric(10,2) [not null,
|
|
95
|
+
"quantity" int4 [not null, check: `quantity > 0`]
|
|
96
|
+
"unit_price" numeric(10,2) [not null, check: `unit_price > (0)::numeric`]
|
|
97
97
|
|
|
98
98
|
Indexes {
|
|
99
99
|
(order_id, product_id) [type: btree, name: "uq_order_product"]
|
|
@@ -134,8 +134,8 @@ Table "user_define_data_types" {
|
|
|
134
134
|
"name" varchar(50)
|
|
135
135
|
"gender" gender_type
|
|
136
136
|
"age" int4range
|
|
137
|
-
"height" float8 [
|
|
138
|
-
"weight" float8 [
|
|
137
|
+
"height" float8 [check: `height > (0)::double precision`]
|
|
138
|
+
"weight" float8 [check: `weight > (0)::double precision`]
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
Table "table_with_comments" {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/cli",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/cli": "^7.21.0",
|
|
29
|
-
"@dbml/connector": "^5.0.0
|
|
30
|
-
"@dbml/core": "^5.0.0
|
|
29
|
+
"@dbml/connector": "^5.0.0",
|
|
30
|
+
"@dbml/core": "^5.0.0",
|
|
31
31
|
"bluebird": "^3.5.5",
|
|
32
32
|
"chalk": "^2.4.2",
|
|
33
33
|
"commander": "^2.20.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"^.+\\.js$": "babel-jest"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "a2d029e9c3c78ab0956312495165ec3115b5bc00",
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=18"
|
|
61
61
|
}
|