@dbml/cli 5.5.1 → 5.6.0-alpha.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 (95) hide show
  1. package/__tests__/db2dbml/mssql/dbml-error.log +22 -0
  2. package/__tests__/db2dbml/mysql/dbml-error.log +6 -0
  3. package/__tests__/db2dbml/oracle/dbml-error.log +28 -0
  4. package/__tests__/db2dbml/postgres/dbml-error.log +14 -0
  5. package/__tests__/dbml2sql/filename --mysql --out-file/dbml-error.log +0 -0
  6. package/__tests__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +65 -0
  7. package/__tests__/dbml2sql/filename --mysql stdout/dbml-error.log +0 -0
  8. package/__tests__/dbml2sql/filename --oracle --out-file/dbml-error.log +0 -0
  9. package/__tests__/dbml2sql/filename --oracle --out-file/out-files/schema.sql +61 -0
  10. package/__tests__/dbml2sql/filename --oracle stdout/dbml-error.log +0 -0
  11. package/__tests__/dbml2sql/filename --out-file/dbml-error.log +0 -0
  12. package/__tests__/dbml2sql/filename --out-file/out-files/schema.sql +77 -0
  13. package/__tests__/dbml2sql/filename --postgres --out-file/dbml-error.log +0 -0
  14. package/__tests__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +77 -0
  15. package/__tests__/dbml2sql/filename --postgres stdout/dbml-error.log +0 -0
  16. package/__tests__/dbml2sql/filename stdout/dbml-error.log +0 -0
  17. package/__tests__/dbml2sql/filenames --mysql --out-file/dbml-error.log +0 -0
  18. package/__tests__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +172 -0
  19. package/__tests__/dbml2sql/filenames --mysql stdout/dbml-error.log +0 -0
  20. package/__tests__/dbml2sql/filenames --oracle --out-file/dbml-error.log +0 -0
  21. package/__tests__/dbml2sql/filenames --oracle --out-file/out-files/schema.sql +172 -0
  22. package/__tests__/dbml2sql/filenames --oracle stdout/dbml-error.log +0 -0
  23. package/__tests__/dbml2sql/filenames --out-file/dbml-error.log +0 -0
  24. package/__tests__/dbml2sql/filenames --out-file/out-files/schema.sql +172 -0
  25. package/__tests__/dbml2sql/filenames --postgres --out-file/dbml-error.log +0 -0
  26. package/__tests__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +172 -0
  27. package/__tests__/dbml2sql/filenames --postgres stdout/dbml-error.log +0 -0
  28. package/__tests__/dbml2sql/filenames stdout/dbml-error.log +0 -0
  29. package/__tests__/dbml2sql/multiple_schema_mssql/dbml-error.log +0 -0
  30. package/__tests__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +62 -0
  31. package/__tests__/dbml2sql/multiple_schema_mysql/dbml-error.log +0 -0
  32. package/__tests__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +50 -0
  33. package/__tests__/dbml2sql/multiple_schema_oracle/dbml-error.log +0 -0
  34. package/__tests__/dbml2sql/multiple_schema_oracle/out-files/multiple_schema.out.sql +88 -0
  35. package/__tests__/dbml2sql/multiple_schema_pg/dbml-error.log +0 -0
  36. package/__tests__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +67 -0
  37. package/__tests__/dbml2sql/syntax-error/dbml-error.log +6 -0
  38. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/dbml-error.log +6 -0
  39. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/dbml-error.log +6 -0
  40. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/dbml-error.log +6 -0
  41. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/dbml-error.log +6 -0
  42. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/dbml-error.log +6 -0
  43. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/dbml-error.log +6 -0
  44. package/__tests__/sql2dbml/filename --mssql --out-file/dbml-error.log +0 -0
  45. package/__tests__/sql2dbml/filename --mssql --out-file/out-files/schema.dbml +25 -0
  46. package/__tests__/sql2dbml/filename --mysql --out-file/dbml-error.log +0 -0
  47. package/__tests__/sql2dbml/filename --mysql --out-file/out-files/schema.dbml +74 -0
  48. package/__tests__/sql2dbml/filename --mysql stdout/dbml-error.log +0 -0
  49. package/__tests__/sql2dbml/filename --oracle --out-file/dbml-error.log +0 -0
  50. package/__tests__/sql2dbml/filename --oracle --out-file/out-files/schema.dbml +83 -0
  51. package/__tests__/sql2dbml/filename --out-file/dbml-error.log +0 -0
  52. package/__tests__/sql2dbml/filename --out-file/out-files/schema.dbml +74 -0
  53. package/__tests__/sql2dbml/filename --postgres --out-file/dbml-error.log +0 -0
  54. package/__tests__/sql2dbml/filename --postgres --out-file/out-files/schema.dbml +74 -0
  55. package/__tests__/sql2dbml/filename --postgres stdout/dbml-error.log +0 -0
  56. package/__tests__/sql2dbml/filename --snowflake stdout/dbml-error.log +0 -0
  57. package/__tests__/sql2dbml/filename stdout/dbml-error.log +0 -0
  58. package/__tests__/sql2dbml/filenames --mysql --out-file/dbml-error.log +0 -0
  59. package/__tests__/sql2dbml/filenames --mysql --out-file/out-files/schema.dbml +170 -0
  60. package/__tests__/sql2dbml/filenames --mysql stdout/dbml-error.log +0 -0
  61. package/__tests__/sql2dbml/filenames --out-file/dbml-error.log +0 -0
  62. package/__tests__/sql2dbml/filenames --out-file/out-files/schema.dbml +170 -0
  63. package/__tests__/sql2dbml/filenames --postgres --out-file/dbml-error.log +0 -0
  64. package/__tests__/sql2dbml/filenames --postgres --out-file/out-files/schema.dbml +170 -0
  65. package/__tests__/sql2dbml/filenames --postgres stdout/dbml-error.log +0 -0
  66. package/__tests__/sql2dbml/filenames stdout/dbml-error.log +0 -0
  67. package/__tests__/sql2dbml/multiple_schema_mssql/dbml-error.log +0 -0
  68. package/__tests__/sql2dbml/multiple_schema_mssql/out-files/multiple_schema.out.dbml +58 -0
  69. package/__tests__/sql2dbml/multiple_schema_mysql/dbml-error.log +0 -0
  70. package/__tests__/sql2dbml/multiple_schema_mysql/out-files/multiple_schema.out.dbml +136 -0
  71. package/__tests__/sql2dbml/multiple_schema_pg/dbml-error.log +0 -0
  72. package/__tests__/sql2dbml/multiple_schema_pg/out-files/multiple_schema.out.dbml +101 -0
  73. package/__tests__/sql2dbml/syntax-error/dbml-error.log +6 -0
  74. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +6 -0
  75. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +6 -0
  76. package/eslint.config.ts +13 -6
  77. package/lib/index.js +374 -20
  78. package/package.json +9 -26
  79. package/tsconfig.json +2 -1
  80. package/vite.config.ts +50 -0
  81. package/.babelrc +0 -19
  82. package/jest.config.ts +0 -14
  83. package/lib/cli/config.js +0 -29
  84. package/lib/cli/connector.js +0 -38
  85. package/lib/cli/export.js +0 -37
  86. package/lib/cli/import.js +0 -36
  87. package/lib/cli/index.js +0 -76
  88. package/lib/cli/outputPlugins/outputConsolePlugin.js +0 -12
  89. package/lib/cli/outputPlugins/outputFilePlugin.js +0 -28
  90. package/lib/cli/utils.js +0 -81
  91. package/lib/cli/validatePlugins/validatePlugins.js +0 -14
  92. package/lib/errors/domainError.js +0 -15
  93. package/lib/errors/index.js +0 -20
  94. package/lib/errors/syntaxError.js +0 -23
  95. package/lib/helpers/logger.js +0 -74
@@ -0,0 +1,88 @@
1
+ -- SQL dump generated using DBML (dbml.dbdiagram.io)
2
+ -- Database: Oracle
3
+ -- Generated at: 2026-02-05T04:33:26.425Z
4
+
5
+ CREATE USER "C##test01"
6
+ NO AUTHENTICATION
7
+ DEFAULT TABLESPACE system
8
+ TEMPORARY TABLESPACE temp
9
+ QUOTA UNLIMITED ON system;
10
+
11
+ CREATE USER "C##test02"
12
+ NO AUTHENTICATION
13
+ DEFAULT TABLESPACE system
14
+ TEMPORARY TABLESPACE temp
15
+ QUOTA UNLIMITED ON system;
16
+
17
+ CREATE TABLE "users" (
18
+ "id" int PRIMARY KEY
19
+ );
20
+
21
+ CREATE TABLE "products" (
22
+ "id" int PRIMARY KEY,
23
+ "user_id" int NOT NULL
24
+ );
25
+
26
+ CREATE TABLE "C##test02"."users_products" (
27
+ "users_id" int,
28
+ "products_id" int,
29
+ PRIMARY KEY ("users_id", "products_id")
30
+ );
31
+
32
+ CREATE TABLE "users_products" (
33
+ "users_id" int,
34
+ "products_id" int,
35
+ PRIMARY KEY ("users_id", "products_id")
36
+ );
37
+
38
+ CREATE TABLE "C##test01"."users_products" (
39
+ "users_id" int,
40
+ "products_id" int,
41
+ PRIMARY KEY ("users_id", "products_id")
42
+ );
43
+
44
+ CREATE TABLE "C##test01"."users" (
45
+ "id" int PRIMARY KEY
46
+ );
47
+
48
+ CREATE TABLE "C##test01"."products" (
49
+ "id" int PRIMARY KEY,
50
+ "user_id" int NOT NULL
51
+ );
52
+
53
+ CREATE TABLE "C##test02"."users" (
54
+ "id" int PRIMARY KEY
55
+ );
56
+
57
+ CREATE TABLE "C##test02"."products" (
58
+ "id" int PRIMARY KEY,
59
+ "user_id" int NOT NULL
60
+ );
61
+
62
+ GRANT REFERENCES ON "C##test01"."users" TO PUBLIC;
63
+
64
+ GRANT REFERENCES ON "users" TO PUBLIC;
65
+
66
+ GRANT REFERENCES ON "C##test02"."users" TO PUBLIC;
67
+
68
+ GRANT REFERENCES ON "products" TO PUBLIC;
69
+
70
+ GRANT REFERENCES ON "C##test02"."products" TO PUBLIC;
71
+
72
+ ALTER TABLE "products" ADD FOREIGN KEY ("user_id") REFERENCES "C##test01"."users" ("id");
73
+
74
+ ALTER TABLE "C##test01"."products" ADD FOREIGN KEY ("user_id") REFERENCES "users" ("id");
75
+
76
+ ALTER TABLE "C##test01"."products" ADD FOREIGN KEY ("user_id") REFERENCES "C##test01"."users" ("id");
77
+
78
+ ALTER TABLE "C##test02"."users_products" ADD FOREIGN KEY ("users_id") REFERENCES "C##test02"."users" ("id");
79
+
80
+ ALTER TABLE "C##test02"."users_products" ADD FOREIGN KEY ("products_id") REFERENCES "products" ("id");
81
+
82
+ ALTER TABLE "users_products" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id");
83
+
84
+ ALTER TABLE "users_products" ADD FOREIGN KEY ("products_id") REFERENCES "C##test02"."products" ("id");
85
+
86
+ ALTER TABLE "C##test01"."users_products" ADD FOREIGN KEY ("users_id") REFERENCES "C##test01"."users" ("id");
87
+
88
+ ALTER TABLE "C##test01"."users_products" ADD FOREIGN KEY ("products_id") REFERENCES "C##test02"."products" ("id");
@@ -0,0 +1,67 @@
1
+ -- SQL dump generated using DBML (dbml.dbdiagram.io)
2
+ -- Database: PostgreSQL
3
+ -- Generated at: 2026-02-05T04:33:27.591Z
4
+
5
+ CREATE SCHEMA "schemaB";
6
+
7
+ CREATE SCHEMA "ecommerce";
8
+
9
+ CREATE SCHEMA "schemaA";
10
+
11
+ CREATE TYPE "job_status" AS ENUM (
12
+ 'created2',
13
+ 'running2',
14
+ 'done2',
15
+ 'failure2'
16
+ );
17
+
18
+ CREATE TYPE "gender" AS ENUM (
19
+ 'male2',
20
+ 'female2'
21
+ );
22
+
23
+ CREATE TYPE "schemaB"."gender" AS ENUM (
24
+ 'male',
25
+ 'female'
26
+ );
27
+
28
+ CREATE TABLE "users" (
29
+ "id" int PRIMARY KEY,
30
+ "name" varchar,
31
+ "pjs" job_status,
32
+ "pjs2" job_status,
33
+ "pg" "schemaB".gender,
34
+ "pg2" gender
35
+ );
36
+
37
+ CREATE TABLE "products" (
38
+ "id" int PRIMARY KEY,
39
+ "name" varchar
40
+ );
41
+
42
+ CREATE TABLE "ecommerce"."users" (
43
+ "id" int PRIMARY KEY,
44
+ "name" varchar,
45
+ "ejs" job_status,
46
+ "ejs2" job_status,
47
+ "eg" "schemaB".gender,
48
+ "eg2" gender
49
+ );
50
+
51
+ CREATE TABLE "schemaA"."products" (
52
+ "id" int PRIMARY KEY,
53
+ "name" varchar
54
+ );
55
+
56
+ CREATE TABLE "schemaA"."locations" (
57
+ "id" int PRIMARY KEY,
58
+ "name" varchar
59
+ );
60
+
61
+ ALTER TABLE "schemaA"."products" ADD FOREIGN KEY ("name") REFERENCES "ecommerce"."users" ("id");
62
+
63
+ ALTER TABLE "schemaA"."locations" ADD FOREIGN KEY ("name") REFERENCES "users" ("id");
64
+
65
+ ALTER TABLE "ecommerce"."users" ADD FOREIGN KEY ("id") REFERENCES "users" ("id");
66
+
67
+ ALTER TABLE "ecommerce"."users" ADD CONSTRAINT "name_optional" FOREIGN KEY ("id") REFERENCES "users" ("name");
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:14:58.006Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:28.839Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:14:59.552Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:30.285Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:15:01.015Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:31.674Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:15:02.546Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:33.028Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:15:04.089Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:34.385Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:15:05.553Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:35.690Z
5
+ undefined
6
+
@@ -0,0 +1,6 @@
1
+ 2026-02-04T14:15:07.054Z
2
+ undefined
3
+
4
+ 2026-02-05T04:33:37.013Z
5
+ undefined
6
+
@@ -0,0 +1,25 @@
1
+ Table "UserMaster" {
2
+ "UserMasterKey" "BIGINT IDENTITY(1,1)" [not null]
3
+ }
4
+
5
+ Table "CodeDef" {
6
+ "CdKey" "BIGINT IDENTITY(1,1)" [not null]
7
+ "Category" NVARCHAR(50) [not null]
8
+ "Description" NVARCHAR(100)
9
+ "Code" NVARCHAR(50) [not null]
10
+ "ParentCdKey" BIGINT
11
+ "UserMasterKeyAddedBy" BIGINT [not null]
12
+ "UserMasterKeyLastEditedBy" BIGINT
13
+ "AddedDtTm" DATETIMEOFFSET(7) [not null]
14
+ "LastEditedDtTm" DATETIMEOFFSET(7)
15
+ "EffectiveFromDtTm" DATETIMEOFFSET(7) [not null]
16
+ "EffectiveThruDtTm" DATETIMEOFFSET(7)
17
+
18
+ Indexes {
19
+ CdKey [pk, name: "PK__CodeDef__4922449ECDD244C3"]
20
+ }
21
+ }
22
+
23
+ Ref "fk__CodeDef__ParentCdKey__CodeDef__CdKey":"CodeDef"."CdKey" < "CodeDef"."ParentCdKey"
24
+
25
+ Ref "fk__CodeDef__UserMasterKeyLastEditedBy__UserMaster_UserMasterKey":"UserMaster"."UserMasterKey" < "CodeDef"."UserMasterKeyLastEditedBy"
@@ -0,0 +1,74 @@
1
+ Enum "orders_status_enum" {
2
+ "created"
3
+ "running"
4
+ "done"
5
+ "failure"
6
+ }
7
+
8
+ Enum "products_status_enum" {
9
+ "Out of Stock"
10
+ "In Stock"
11
+ }
12
+
13
+ Table "orders" {
14
+ "id" int [pk, increment]
15
+ "user_id" int [unique, not null]
16
+ "status" orders_status_enum
17
+ "created_at" varchar(255)
18
+ }
19
+
20
+ Table "order_items" {
21
+ "order_id" int
22
+ "product_id" int
23
+ "quantity" int [default: 1]
24
+ }
25
+
26
+ Table "products" {
27
+ "id" int [pk]
28
+ "name" varchar(255)
29
+ "merchant_id" int [not null]
30
+ "price" int
31
+ "status" products_status_enum
32
+ "created_at" datetime [default: `now()`]
33
+
34
+ Indexes {
35
+ (merchant_id, status) [name: "product_status"]
36
+ id [type: hash, unique, name: "products_index_1"]
37
+ }
38
+ }
39
+
40
+ Table "users" {
41
+ "id" int [pk]
42
+ "full_name" varchar(255)
43
+ "email" varchar(255) [unique]
44
+ "gender" varchar(255)
45
+ "date_of_birth" varchar(255)
46
+ "created_at" varchar(255)
47
+ "country_code" int
48
+ }
49
+
50
+ Table "merchants" {
51
+ "id" int [pk]
52
+ "merchant_name" varchar(255)
53
+ "country_code" int
54
+ "created_at" varchar(255)
55
+ "admin_id" int
56
+ }
57
+
58
+ Table "countries" {
59
+ "code" int [pk]
60
+ "name" varchar(255)
61
+ "continent_name" varchar(255)
62
+ }
63
+
64
+ Ref:"orders"."id" < "order_items"."order_id"
65
+
66
+ Ref:"products"."id" < "order_items"."product_id"
67
+
68
+ Ref:"countries"."code" < "users"."country_code"
69
+
70
+ Ref:"countries"."code" < "merchants"."country_code"
71
+
72
+ Ref:"merchants"."id" < "products"."merchant_id"
73
+
74
+ Ref:"users"."id" < "merchants"."admin_id"
@@ -0,0 +1,83 @@
1
+ Table "departments" {
2
+ "dept_id" NUMBER(10) [pk]
3
+ "dept_name" VARCHAR2(100)
4
+ "location_id" NUMBER(10)
5
+ "manager_id" NUMBER(10)
6
+ }
7
+
8
+ Table "locations" {
9
+ "location_id" NUMBER(10) [pk]
10
+ "city" VARCHAR2(100)
11
+ "country_code" CHAR(2)
12
+ }
13
+
14
+ Table "countries" {
15
+ "country_code" CHAR(2) [pk]
16
+ "country_name" VARCHAR2(100)
17
+ }
18
+
19
+ Table "employees" {
20
+ "emp_id" NUMBER(10) [pk]
21
+ "emp_name" VARCHAR2(100)
22
+ "department_id" NUMBER(10)
23
+ "manager_id" NUMBER(10)
24
+ "hire_date" DATE
25
+ "location_id" NUMBER(10)
26
+ }
27
+
28
+ Table "projects" {
29
+ "project_id" NUMBER(10) [pk]
30
+ "project_name" VARCHAR2(200)
31
+ "dept_id" NUMBER(10)
32
+ "lead_emp_id" NUMBER(10)
33
+ "backup_emp_id" NUMBER(10)
34
+ }
35
+
36
+ Table "assignments" {
37
+ "assignment_id" NUMBER(10) [pk]
38
+ "emp_id" NUMBER(10)
39
+ "project_id" NUMBER(10)
40
+ "start_date" DATE
41
+ }
42
+
43
+ Table "project_tasks" {
44
+ "project_id" NUMBER(10)
45
+ "task_id" NUMBER(10)
46
+ "task_name" VARCHAR2(200)
47
+ "assigned_emp_id" NUMBER(10)
48
+
49
+ Indexes {
50
+ (project_id, task_id) [pk]
51
+ }
52
+ }
53
+
54
+ Table "task_hours" {
55
+ "hour_id" NUMBER(10) [pk]
56
+ "project_id" NUMBER(10)
57
+ "task_id" NUMBER(10)
58
+ "hours_worked" NUMBER(5,2)
59
+ }
60
+
61
+ Ref "fk_emp_dept":"departments"."dept_id" < "employees"."department_id"
62
+
63
+ Ref "fk_dept_location":"locations"."location_id" < "departments"."location_id"
64
+
65
+ Ref "fk_loc_country":"countries"."country_code" < "locations"."country_code"
66
+
67
+ Ref "fk_emp_manager":"employees"."emp_id" < "employees"."manager_id"
68
+
69
+ Ref "fk_dept_manager":"employees"."emp_id" < "departments"."manager_id"
70
+
71
+ Ref:"departments"."dept_id" < "projects"."dept_id"
72
+
73
+ Ref:"employees"."emp_id" < "assignments"."emp_id"
74
+
75
+ Ref:"projects"."project_id" < "assignments"."project_id"
76
+
77
+ Ref "fk_task_hours_project_task":"project_tasks".("project_id", "task_id") < "task_hours".("project_id", "task_id")
78
+
79
+ Ref "fk_proj_lead_emp":"employees"."emp_id" < "projects"."lead_emp_id"
80
+
81
+ Ref "fk_proj_backup_emp":"employees"."emp_id" < "projects"."backup_emp_id"
82
+
83
+ Ref "fk_task_assigned_emp":"employees"."emp_id" < "project_tasks"."assigned_emp_id"
@@ -0,0 +1,74 @@
1
+ Enum "orders_status" {
2
+ "created"
3
+ "running"
4
+ "done"
5
+ "failure"
6
+ }
7
+
8
+ Enum "product status" {
9
+ "Out of Stock"
10
+ "In Stock"
11
+ }
12
+
13
+ Table "orders" {
14
+ "id" SERIAL [pk, increment]
15
+ "user_id" int [unique, not null]
16
+ "status" orders_status
17
+ "created_at" varchar
18
+ }
19
+
20
+ Table "order_items" {
21
+ "order_id" int
22
+ "product_id" int
23
+ "quantity" int [default: 1]
24
+ }
25
+
26
+ Table "products" {
27
+ "id" int [pk]
28
+ "name" varchar
29
+ "merchant_id" int [not null]
30
+ "price" int
31
+ "status" "product status"
32
+ "created_at" datetime [default: `now()`]
33
+
34
+ Indexes {
35
+ (merchant_id, status) [name: "product_status"]
36
+ id [type: hash, unique]
37
+ }
38
+ }
39
+
40
+ Table "users" {
41
+ "id" int [pk]
42
+ "full_name" varchar
43
+ "email" varchar [unique]
44
+ "gender" varchar
45
+ "date_of_birth" varchar
46
+ "created_at" varchar
47
+ "country_code" int
48
+ }
49
+
50
+ Table "merchants" {
51
+ "id" int [pk]
52
+ "merchant_name" varchar
53
+ "country_code" int
54
+ "created_at" varchar
55
+ "admin_id" int
56
+ }
57
+
58
+ Table "countries" {
59
+ "code" int [pk]
60
+ "name" varchar
61
+ "continent_name" varchar
62
+ }
63
+
64
+ Ref:"orders"."id" < "order_items"."order_id"
65
+
66
+ Ref:"products"."id" < "order_items"."product_id"
67
+
68
+ Ref:"countries"."code" < "users"."country_code"
69
+
70
+ Ref:"countries"."code" < "merchants"."country_code"
71
+
72
+ Ref:"merchants"."id" < "products"."merchant_id"
73
+
74
+ Ref:"users"."id" < "merchants"."admin_id"
@@ -0,0 +1,74 @@
1
+ Enum "orders_status" {
2
+ "created"
3
+ "running"
4
+ "done"
5
+ "failure"
6
+ }
7
+
8
+ Enum "product status" {
9
+ "Out of Stock"
10
+ "In Stock"
11
+ }
12
+
13
+ Table "orders" {
14
+ "id" SERIAL [pk, increment]
15
+ "user_id" int [unique, not null]
16
+ "status" orders_status
17
+ "created_at" varchar
18
+ }
19
+
20
+ Table "order_items" {
21
+ "order_id" int
22
+ "product_id" int
23
+ "quantity" int [default: 1]
24
+ }
25
+
26
+ Table "products" {
27
+ "id" int [pk]
28
+ "name" varchar
29
+ "merchant_id" int [not null]
30
+ "price" int
31
+ "status" "product status"
32
+ "created_at" datetime [default: `now()`]
33
+
34
+ Indexes {
35
+ (merchant_id, status) [name: "product_status"]
36
+ id [type: hash, unique]
37
+ }
38
+ }
39
+
40
+ Table "users" {
41
+ "id" int [pk]
42
+ "full_name" varchar
43
+ "email" varchar [unique]
44
+ "gender" varchar
45
+ "date_of_birth" varchar
46
+ "created_at" varchar
47
+ "country_code" int
48
+ }
49
+
50
+ Table "merchants" {
51
+ "id" int [pk]
52
+ "merchant_name" varchar
53
+ "country_code" int
54
+ "created_at" varchar
55
+ "admin_id" int
56
+ }
57
+
58
+ Table "countries" {
59
+ "code" int [pk]
60
+ "name" varchar
61
+ "continent_name" varchar
62
+ }
63
+
64
+ Ref:"orders"."id" < "order_items"."order_id"
65
+
66
+ Ref:"products"."id" < "order_items"."product_id"
67
+
68
+ Ref:"countries"."code" < "users"."country_code"
69
+
70
+ Ref:"countries"."code" < "merchants"."country_code"
71
+
72
+ Ref:"merchants"."id" < "products"."merchant_id"
73
+
74
+ Ref:"users"."id" < "merchants"."admin_id"