@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
@@ -1,219 +0,0 @@
1
- Table "dbo"."users" {
2
- "user_id" int(10) [pk, not null, increment]
3
- "username" varchar(50) [unique, not null]
4
- "email" varchar(100) [unique, not null, check: `[email] like '%_@_%._%'`]
5
- "password_hash" varchar(255) [not null]
6
- "first_name" varchar(50)
7
- "last_name" varchar(50)
8
- "full_name" varchar(100)
9
- "full_name_lower" varchar(100)
10
- "date_of_birth" date [check: `[date_of_birth]<=dateadd(year,(-13),getdate())`]
11
- "created_at" datetime2 [default: `getdate()`]
12
- "last_login" datetime2
13
- "is_active" bit [default: 1]
14
-
15
- Indexes {
16
- email [type: nonclustered, name: "idx_users_email"]
17
- full_name [type: nonclustered, name: "idx_users_full_name"]
18
- (is_active, full_name_lower) [type: nonclustered, name: "idx_users_is_active_full_name"]
19
- }
20
- }
21
-
22
- Table "dbo"."products" {
23
- "product_id" int(10) [pk, not null, increment]
24
- "name" varchar(100) [not null]
25
- "description" text
26
- "price" decimal(10,2) [not null, check: `[price]>(0)`]
27
- "stock_quantity" int(10) [not null, check: `[stock_quantity]>=(0)`, default: 0]
28
- "category" varchar(50)
29
- "created_at" datetime2 [default: `getdate()`]
30
- "updated_at" datetime2 [default: `getdate()`]
31
- "is_available" bit [default: 1]
32
-
33
- Indexes {
34
- category [type: nonclustered, name: "idx_products_category"]
35
- }
36
- }
37
-
38
- Table "dbo"."orders" {
39
- "order_id" int(10) [pk, not null, increment]
40
- "user_id" int(10) [not null]
41
- "order_date" datetime2 [default: `getdate()`]
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
- "shipping_address" text [not null]
45
- "billing_address" text [not null]
46
-
47
- Indexes {
48
- (user_id, order_date) [type: nonclustered, name: "idx_orders_user_date"]
49
- }
50
- }
51
-
52
- Table "dbo"."order_items" {
53
- "order_item_id" int(10) [pk, not null, increment]
54
- "order_id" int(10) [unique, not null]
55
- "product_id" int(10) [unique, not null]
56
- "quantity" int(10) [not null, check: `[quantity]>(0)`]
57
- "unit_price" decimal(10,2) [not null, check: `[unit_price]>(0)`]
58
-
59
- Indexes {
60
- (order_id, product_id) [type: nonclustered, name: "idx_order_items_order_product"]
61
- }
62
- }
63
-
64
- Table "dbo"."StringTypes" {
65
- "Id" int(10) [pk, not null, increment]
66
- "CharField" char(10) [default: 'N/A']
67
- "VarcharField" varchar(50) [default: '{"default_key": "default_value"}']
68
- "VarcharMaxField" varchar(MAX) [default: 'N/A']
69
- "TextField" text [default: 'N/A']
70
- "NCharField" nchar(10) [default: `N'N/A'`]
71
- "NVarCharField" nvarchar(50) [default: `N'N/A'`]
72
- "NVarCharMaxField" nvarchar(MAX) [default: `N'N/A'`]
73
- "NTextField" ntext [default: `N'N/A'`]
74
- }
75
-
76
- Table "dbo"."NumberTypes" {
77
- "ID" int(10) [pk, not null, increment]
78
- "TINYINTCol" tinyint(3) [default: 0]
79
- "SMALLINTCol" smallint(5) [default: 0]
80
- "INTCol" int(10) [default: 0]
81
- "BIGINTCol" bigint(19) [default: 0]
82
- "DECIMALCol" decimal(10,2) [default: 0.00]
83
- "NUMERICCol" numeric(10,2) [default: 0.00]
84
- "FLOATCol" float(53) [default: 0.0]
85
- "REALCol" real(24) [default: 0.0]
86
- "BITCol" bit [default: 0]
87
- }
88
-
89
- Table "dbo"."NumberTypesNoDefault" {
90
- "ID" int(10) [pk, not null, increment]
91
- "TINYINTCol" tinyint(3)
92
- "SMALLINTCol" smallint(5)
93
- "INTCol" int(10)
94
- "BIGINTCol" bigint(19)
95
- "DECIMALCol" decimal(10,2)
96
- "NUMERICCol" numeric(10,2)
97
- "FLOATCol" float(53)
98
- "REALCol" real(24)
99
- "BITCol" bit
100
- }
101
-
102
- Table "dbo"."DatetimeTypes" {
103
- "ID" int(10) [pk, not null, increment]
104
- "DATECol" date [default: `getdate()`]
105
- "TIMECol" time [default: `CONVERT([time],getdate())`]
106
- "DATETIMECol" datetime [default: `getdate()`]
107
- "DATETIME2Col" datetime2 [default: `sysdatetime()`]
108
- "SMALLDATETIMECol" smalldatetime [default: `getdate()`]
109
- "ROWVERSIONCol" timestamp [not null]
110
- "DATETIMEOFFSETCol" datetimeoffset [default: `sysdatetimeoffset()`]
111
- }
112
-
113
- Table "dbo"."ObjectTypes" {
114
- "Id" int(10) [pk, not null, increment]
115
- "XmlField" xml [default: '''<Books>
116
- <Book>
117
- <Title>The Great Gatsby</Title>
118
- <Author>F. Scott Fitzgerald</Author>
119
- <Year>1925</Year>
120
- <Price>10.99</Price>
121
- <Publisher>Scribner</Publisher>
122
- <Location>New York</Location>
123
- <Genre>Fiction</Genre>
124
- <Subgenre>Classic</Subgenre>
125
- </Book>
126
- <Book>
127
- <Title>1984</Title>
128
- <Author>George Orwell</Author>
129
- <Year>1949</Year>
130
- <Price>8.99</Price>
131
- <Publisher>Secker & Warburg</Publisher>
132
- <Location>London</Location>
133
- <Genre>Dystopian</Genre>
134
- <Subgenre>Political Fiction</Subgenre>
135
- </Book>
136
- </Books>''']
137
- "JsonField" nvarchar(MAX) [default: `N'{"defaultKey": "defaultValue", "status": "active", "count": 0}'`]
138
- "BinaryField" binary(50) [default: `0x00`]
139
- "VarBinaryField" varbinary(50) [default: `0x00`]
140
- "VarBinaryMaxField" varbinary(MAX) [default: `0x00`]
141
- "ImageField" image [default: `0x00`]
142
- }
143
-
144
- Table "dbo"."gender_reference" {
145
- "value" nvarchar(10) [pk, not null]
146
- }
147
-
148
- Table "dbo"."user_define_data_types" {
149
- "id" int(10) [pk, not null, increment]
150
- "name" nvarchar(50)
151
- "gender" nvarchar(10) [check: `[gender]='Other' OR [gender]='Female' OR [gender]='Male'`]
152
- "age_start" int(10)
153
- "age_end" int(10)
154
- "height" float(53)
155
- "weight" float(53)
156
-
157
- Checks {
158
- `[age_start]<=[age_end]` [name: 'chk_age_range']
159
- }
160
- }
161
-
162
- Table "dbo"."table_with_comments" {
163
- "id" int(10) [pk, not null, increment, note: 'Unique identifier for each item.']
164
- "name" varchar(100) [note: 'Name of the item.']
165
- "description" text [note: '''Item\'s description''']
166
- "created_at" datetime2 [default: `getdate()`, note: 'Timestamp when the item was created.']
167
- Note: 'This table stores information about various items.'
168
- }
169
-
170
- Table "dbo"."Authors" {
171
- "AuthorID" int(10) [pk, not null]
172
- "NationalityID" int(10) [pk, not null]
173
- "AuthorName" nvarchar(100) [unique]
174
- "BirthYear" int(10) [unique]
175
- }
176
-
177
- Table "dbo"."Books" {
178
- "BookID" int(10) [pk, not null]
179
- "AuthorID" int(10) [pk, not null]
180
- "NationalityID" int(10)
181
- "ISBN" nvarchar(20) [unique]
182
- "Title" nvarchar(200)
183
- }
184
-
185
- Table "dbo"."AddressInfo" {
186
- "AddressID" uniqueidentifier(16) [not null]
187
- "AddressFormatID" uniqueidentifier(16) [not null]
188
-
189
- Checks {
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
- }
192
- }
193
-
194
- Table "dbo"."AddressInfo2" {
195
- "A1" uniqueidentifier(16) [not null]
196
- "A2" uniqueidentifier(16) [not null]
197
- "A3" uniqueidentifier(16) [not null]
198
- "A4" uniqueidentifier(16) [not null]
199
-
200
- Checks {
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
- }
203
- }
204
-
205
- Table "dbo"."TestDescriptionTable" {
206
- "Id" int(10) [note: 'Primary key identifier.']
207
- "Name" nvarchar(100) [check: `len([Name])>(6)`, note: 'Name of the entity.']
208
- Note: 'This is the custom comment name on table.'
209
- }
210
-
211
- Ref "FK_AuthorNationality":"dbo"."Authors".("AuthorID", "NationalityID") < "dbo"."Books".("AuthorID", "NationalityID")
212
-
213
- Ref "fk_product":"dbo"."products"."product_id" < "dbo"."order_items"."product_id" [update: cascade]
214
-
215
- Ref "fk_order":"dbo"."orders"."order_id" < "dbo"."order_items"."order_id" [update: cascade, delete: cascade]
216
-
217
- Ref "fk_user":"dbo"."users"."user_id" < "dbo"."orders"."user_id" [update: cascade, delete: cascade]
218
-
219
- Ref "fk_gender":"dbo"."gender_reference"."value" < "dbo"."user_define_data_types"."gender"
@@ -1,188 +0,0 @@
1
- Enum "status_example_2_s1_enum" {
2
- "active"
3
- "inactive"
4
- "pending"
5
- }
6
-
7
- Enum "status_example_2_s2_enum" {
8
- "active"
9
- "inactive"
10
- "pending"
11
- }
12
-
13
- Enum "status_example_2_s3_enum" {
14
- "active"
15
- "inactive"
16
- "pending"
17
- }
18
-
19
- Enum "status_example_2_s4_enum" {
20
- "active"
21
- "inactive"
22
- "pending"
23
- }
24
-
25
- Enum "status_example_2_s5_enum" {
26
- "0"
27
- "1"
28
- "2"
29
- }
30
-
31
- Enum "status_example_2_s6_enum" {
32
- "0"
33
- "1"
34
- "2"
35
- }
36
-
37
- Enum "status_example_2_s7_enum" {
38
- "0"
39
- "1"
40
- "2"
41
- }
42
-
43
- Enum "status_example_2_s8_enum" {
44
- "0"
45
- "1"
46
- "2"
47
- }
48
-
49
- Table "categories" {
50
- "cat_id" "int unsigned" [pk, not null, increment]
51
- "cat_name" varchar(50) [not null]
52
- "super_cat_id" "int unsigned"
53
- "created_at" timestamp [default: `CURRENT_TIMESTAMP`]
54
- }
55
-
56
- Table "composite_key_1" {
57
- "id1_1" "int unsigned" [not null]
58
- "id1_2" "int unsigned" [not null]
59
- "email" varchar(255)
60
- "name" varchar(50)
61
-
62
- Indexes {
63
- (id1_1, id1_2) [pk, name: "PRIMARY"]
64
- (email, name) [unique, name: "uc_unique_composite"]
65
- }
66
- }
67
-
68
- Table "composite_key_2" {
69
- "id2_1" "int unsigned" [not null]
70
- "id2_2" "int unsigned" [not null]
71
-
72
- Indexes {
73
- (id2_1, id2_2) [pk, name: "PRIMARY"]
74
- }
75
- }
76
-
77
- Table "date_time_example" {
78
- "default_now" timestamp [default: `CURRENT_TIMESTAMP`]
79
- "default_local" timestamp [default: `CURRENT_TIMESTAMP`]
80
- "date_plus_7_days" date [default: `(curdate() + interval 7 day)`]
81
- "date_minus_30_days" date [default: `(curdate() - interval 30 day)`]
82
- "timestamp_plus_1_hour" timestamp [default: `(now() + interval 1 hour)`]
83
- "timestamp_minus_15_minutes" timestamp [default: `(now() - interval 15 minute)`]
84
- "on_update_1" "datetime on update CURRENT_TIMESTAMP" [default: `CURRENT_TIMESTAMP`]
85
- "on_update_2" "datetime on update CURRENT_TIMESTAMP" [default: `CURRENT_TIMESTAMP`]
86
- }
87
-
88
- Table "default_example" {
89
- "id" int [pk, not null, increment]
90
- "column1" varchar(255) [default: `concat(_utf8mb4\'default \',uuid())`]
91
- "column2" varchar(255) [default: `concat(_utf8mb4\'random \',floor((rand() * 100)))`]
92
- "column3" varchar(255) [default: '_utf8mb4']
93
- "column4" double [default: 0.5]
94
- "created_date" date [default: `curdate()`]
95
- "first_date" date [default: '2023-01-01']
96
- "event_time" timestamp [default: '2024-01-01 00:00:00']
97
- }
98
-
99
- Table "hash_index_example" {
100
- "id" int [pk, not null, note: 'unique identifier for each record']
101
- "name" varchar(100) [note: '''first name\'s of the individual''']
102
- "name1" varchar(100) [note: '''last name\'s of the individual''']
103
-
104
- Indexes {
105
- (name, name1) [type: hash, name: "idx_name_name1"]
106
- }
107
- Note: 'table for storing names with a hash index'
108
- }
109
-
110
- Table "index_example" {
111
- "id" int [pk, not null, increment]
112
- "name_lower" varchar(100) [not null]
113
- "name_inline" varchar(100) [not null]
114
- "email" varchar(100) [unique, not null]
115
- "age" int
116
- "city" varchar(50)
117
-
118
- Indexes {
119
- (city, age) [type: btree, name: "idx_city_age"]
120
- `city(5)` [type: btree, name: "idx_city_part"]
121
- name_inline [type: btree, name: "idx_name"]
122
- `lower(name_lower)` [type: btree, name: "idx_name_lower"]
123
- }
124
- }
125
-
126
- Table "order_items" {
127
- "order_id" "int unsigned" [not null]
128
- "product_id" "int unsigned" [not null]
129
- }
130
-
131
- Table "orders" {
132
- "order_id" "int unsigned" [pk, not null, increment]
133
- "user_id" "int unsigned"
134
- }
135
-
136
- Table "products" {
137
- "id" "int unsigned" [pk, not null, increment]
138
- "price" decimal(10,2) [not null]
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
- "updated_at" "timestamp on update CURRENT_TIMESTAMP" [default: `CURRENT_TIMESTAMP`]
142
-
143
- Checks {
144
- `(`price` > 0) and (`price` < 1000000)` [name: 'products_chk_1']
145
- }
146
- }
147
-
148
- Table "sqrt_triangle" {
149
- "side_a" double
150
- "side_b" double
151
- "side_c" "double GENERATED ALWAYS AS (sqrt(((`side_a` * `side_a`) + (`side_b` * `side_b`)))) VIRTUAL"
152
- }
153
-
154
- Table "status_example_2" {
155
- "s1" status_example_2_s1_enum [not null]
156
- "s2" status_example_2_s2_enum
157
- "s3" status_example_2_s3_enum [default: 'active']
158
- "s4" status_example_2_s4_enum [default: 'pending']
159
- "s5" status_example_2_s5_enum
160
- "s6" status_example_2_s6_enum [not null]
161
- "s7" status_example_2_s7_enum [default: '1']
162
- "s8" status_example_2_s8_enum [default: '0']
163
- }
164
-
165
- Table "users" {
166
- "user_id" "int unsigned" [pk, not null, increment]
167
- "username" varchar(50) [unique, not null]
168
- "email" varchar(100) [unique, not null]
169
- "password_hash" varchar(255) [not null]
170
- "first_name" varchar(50)
171
- "last_name" varchar(50)
172
- "date_of_birth" date
173
- "created_at" timestamp [default: `CURRENT_TIMESTAMP`]
174
- "last_login" timestamp [default: `CURRENT_TIMESTAMP`]
175
- "is_active" tinyint(1) [default: 1]
176
-
177
- Checks {
178
- ``created_at` <= `last_login`` [name: 'chk_last_login']
179
- }
180
- }
181
-
182
- Ref "fk_test_composite":"composite_key_2".("id2_1", "id2_2") < "composite_key_1".("id1_1", "id1_2")
183
-
184
- Ref "fk_detail_items_orders":"orders"."order_id" < "order_items"."order_id" [delete: cascade]
185
-
186
- Ref "fk_detail_items_products":"products"."id" < "order_items"."product_id"
187
-
188
- Ref "fk_order_user":"users"."user_id" < "orders"."user_id" [delete: set null]
@@ -1,184 +0,0 @@
1
- Enum "dbml_test"."enum_type1" {
2
- "value1"
3
- "value2"
4
- }
5
-
6
- Enum "dbml_test"."enum_type3" {
7
- "value4"
8
- "value5"
9
- }
10
-
11
- Table "dbml_test"."table1" {
12
- "id" int4 [pk, not null, increment]
13
- "status" dbml_test.enum_type1
14
- }
15
-
16
- Table "dbml_test"."table3" {
17
- "id" int4 [pk, not null, increment]
18
- "status" dbml_test.enum_type3
19
- }
20
-
21
- Enum "enum_type1" {
22
- "value1"
23
- "value2"
24
- }
25
-
26
- Enum "enum_type2" {
27
- "value1"
28
- "value3"
29
- }
30
-
31
- Enum "gender_type" {
32
- "Male"
33
- "Female"
34
- "Other"
35
- }
36
-
37
- Table "users" {
38
- "user_id" int4 [pk, not null, increment]
39
- "username" varchar(50) [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
- "password_hash" varchar(255) [not null]
42
- "first_name" varchar(50)
43
- "last_name" varchar(50)
44
- "full_name" varchar(100)
45
- "date_of_birth" date [check: `date_of_birth <= (CURRENT_DATE - '13 years'::interval)`]
46
- "created_at" timestamptz [default: `CURRENT_TIMESTAMP`]
47
- "last_login" timestamptz
48
- "is_active" bool [default: true]
49
-
50
- Indexes {
51
- full_name [type: btree, name: "User Name"]
52
- email [type: btree, name: "idx_users_email"]
53
- (is_active, `lower((full_name)::text)`) [type: btree, name: "users_is_active_lower_idx"]
54
- }
55
- }
56
-
57
- Table "products" {
58
- "product_id" int4 [pk, not null, increment]
59
- "name" varchar(100) [not null]
60
- "description" text
61
- "price" numeric(10,2) [not null, check: `price > (0)::numeric`]
62
- "stock_quantity" int4 [not null, check: `stock_quantity >= 0`, default: 0]
63
- "category" varchar(50)
64
- "created_at" timestamptz [default: `CURRENT_TIMESTAMP`]
65
- "updated_at" timestamptz [default: `CURRENT_TIMESTAMP`]
66
- "is_available" bool [default: true]
67
-
68
- Checks {
69
- `created_at <= updated_at` [name: 'chk_created_at']
70
- }
71
-
72
- Indexes {
73
- category [type: btree, name: "idx_products_category"]
74
- }
75
- }
76
-
77
- Table "orders" {
78
- "order_id" int4 [pk, not null, increment]
79
- "user_id" int4 [not null]
80
- "order_date" timestamptz [default: `CURRENT_TIMESTAMP`]
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
- "shipping_address" text [not null]
84
- "billing_address" text [not null]
85
-
86
- Indexes {
87
- (user_id, order_date) [type: btree, name: "idx_orders_user_date"]
88
- }
89
- }
90
-
91
- Table "order_items" {
92
- "order_item_id" int4 [pk, not null, increment]
93
- "order_id" int4 [not null]
94
- "product_id" int4 [not null]
95
- "quantity" int4 [not null, check: `quantity > 0`]
96
- "unit_price" numeric(10,2) [not null, check: `unit_price > (0)::numeric`]
97
-
98
- Indexes {
99
- (order_id, product_id) [type: btree, name: "uq_order_product"]
100
- (order_id, product_id) [type: btree, name: "idx_order_items_order_product"]
101
- }
102
- }
103
-
104
- Table "all_string_types" {
105
- "text_col" text [default: 'default_text']
106
- "varchar_col" varchar(100) [default: 'default_varchar']
107
- "char_col" bpchar(10) [default: 'default_char']
108
- "character_varying_col" varchar(50) [default: 'default_character_varying']
109
- "character_col" bpchar(5) [default: 'default_character']
110
- "name_col" name [default: 'default_name']
111
- "bpchar_col" bpchar(15) [default: 'default_bpchar']
112
- "text_array_col" "text[]" [default: `ARRAY['default_text1', 'default_text2']`]
113
- "json_col" json [default: `{"default_key": "default_value"}`]
114
- "jsonb_col" jsonb [default: `{"default_key": "default_value"}`]
115
- }
116
-
117
- Table "all_default_values" {
118
- "id" int4 [pk, not null, increment]
119
- "boolean_col" bool [default: true]
120
- "integer_col" int4 [default: 42]
121
- "numeric_col" numeric(10,2) [default: 99.99]
122
- "date_col" date [default: `CURRENT_DATE`]
123
- "date_col_specific" date [default: '2024-01-01']
124
- "timestamp_col" timestamp [default: `CURRENT_TIMESTAMP`]
125
- "timestamp_col_specific" timestamp [default: '2024-01-01 12:00:00']
126
- "date_plus_7_days" date [default: `(CURRENT_DATE + '7 days'::interval)`]
127
- "date_minus_30_days" date [default: `(CURRENT_DATE - '30 days'::interval)`]
128
- "timestamp_plus_1_hour" timestamp [default: `(CURRENT_TIMESTAMP + '01:00:00'::interval)`]
129
- "timestamp_minus_15_minutes" timestamp [default: `(CURRENT_TIMESTAMP - '00:15:00'::interval)`]
130
- }
131
-
132
- Table "user_define_data_types" {
133
- "id" int4 [pk, not null, increment]
134
- "name" varchar(50)
135
- "gender" gender_type
136
- "age" int4range
137
- "height" float8 [check: `height > (0)::double precision`]
138
- "weight" float8 [check: `weight > (0)::double precision`]
139
- }
140
-
141
- Table "table_with_comments" {
142
- "id" int4 [pk, not null, increment, note: 'Unique identifier for each item.']
143
- "name" varchar(100) [note: '''Item\'s name.''']
144
- "description" text [note: '''Item\'s description''']
145
- "created_at" timestamptz [default: `CURRENT_TIMESTAMP`, note: 'Timestamp when the item was created.']
146
- Note: '''This table stores information about various items. Such as: \'id\', \'name\', \'description\''''
147
- }
148
-
149
- Table "authors" {
150
- "authorid" int4 [not null, increment]
151
- "nationalityid" int4 [not null]
152
- "authorname" varchar(100)
153
- "birthyear" int4
154
-
155
- Indexes {
156
- (authorid, nationalityid) [type: btree, name: "authors_pkey"]
157
- }
158
- }
159
-
160
- Table "books" {
161
- "bookid" int4 [pk, not null, increment]
162
- "authorid" int4
163
- "nationalityid" int4
164
- "isbn" varchar(20) [unique]
165
- "title" varchar(200)
166
- }
167
-
168
- Table "table1" {
169
- "id" int4 [pk, not null, increment]
170
- "status" enum_type1
171
- }
172
-
173
- Table "table2" {
174
- "id" int4 [pk, not null, increment]
175
- "status" enum_type2
176
- }
177
-
178
- Ref "fk_authornationality":"authors".("authorid", "nationalityid") < "books".("authorid", "nationalityid") [delete: cascade]
179
-
180
- Ref "fk_order":"orders"."order_id" < "order_items"."order_id" [delete: cascade]
181
-
182
- Ref "fk_product":"products"."product_id" < "order_items"."product_id" [delete: cascade]
183
-
184
- Ref "fk_user":"users"."user_id" < "orders"."user_id" [delete: cascade]