@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.
- package/__tests__/db2dbml/mssql/dbml-error.log +22 -0
- package/__tests__/db2dbml/mysql/dbml-error.log +6 -0
- package/__tests__/db2dbml/oracle/dbml-error.log +28 -0
- package/__tests__/db2dbml/postgres/dbml-error.log +14 -0
- package/__tests__/dbml2sql/filename --mysql --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +65 -0
- package/__tests__/dbml2sql/filename --mysql stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --oracle --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --oracle --out-file/out-files/schema.sql +61 -0
- package/__tests__/dbml2sql/filename --oracle stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --out-file/out-files/schema.sql +77 -0
- package/__tests__/dbml2sql/filename --postgres --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +77 -0
- package/__tests__/dbml2sql/filename --postgres stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filename stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --mysql --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +172 -0
- package/__tests__/dbml2sql/filenames --mysql stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --oracle --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --oracle --out-file/out-files/schema.sql +172 -0
- package/__tests__/dbml2sql/filenames --oracle stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --out-file/out-files/schema.sql +172 -0
- package/__tests__/dbml2sql/filenames --postgres --out-file/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +172 -0
- package/__tests__/dbml2sql/filenames --postgres stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/filenames stdout/dbml-error.log +0 -0
- package/__tests__/dbml2sql/multiple_schema_mssql/dbml-error.log +0 -0
- package/__tests__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +62 -0
- package/__tests__/dbml2sql/multiple_schema_mysql/dbml-error.log +0 -0
- package/__tests__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +50 -0
- package/__tests__/dbml2sql/multiple_schema_oracle/dbml-error.log +0 -0
- package/__tests__/dbml2sql/multiple_schema_oracle/out-files/multiple_schema.out.sql +88 -0
- package/__tests__/dbml2sql/multiple_schema_pg/dbml-error.log +0 -0
- package/__tests__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +67 -0
- package/__tests__/dbml2sql/syntax-error/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/dbml-error.log +6 -0
- package/__tests__/sql2dbml/filename --mssql --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --mssql --out-file/out-files/schema.dbml +25 -0
- package/__tests__/sql2dbml/filename --mysql --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --mysql --out-file/out-files/schema.dbml +74 -0
- package/__tests__/sql2dbml/filename --mysql stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --oracle --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --oracle --out-file/out-files/schema.dbml +83 -0
- package/__tests__/sql2dbml/filename --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --out-file/out-files/schema.dbml +74 -0
- package/__tests__/sql2dbml/filename --postgres --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --postgres --out-file/out-files/schema.dbml +74 -0
- package/__tests__/sql2dbml/filename --postgres stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename --snowflake stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filename stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames --mysql --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames --mysql --out-file/out-files/schema.dbml +170 -0
- package/__tests__/sql2dbml/filenames --mysql stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames --out-file/out-files/schema.dbml +170 -0
- package/__tests__/sql2dbml/filenames --postgres --out-file/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames --postgres --out-file/out-files/schema.dbml +170 -0
- package/__tests__/sql2dbml/filenames --postgres stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/filenames stdout/dbml-error.log +0 -0
- package/__tests__/sql2dbml/multiple_schema_mssql/dbml-error.log +0 -0
- package/__tests__/sql2dbml/multiple_schema_mssql/out-files/multiple_schema.out.dbml +58 -0
- package/__tests__/sql2dbml/multiple_schema_mysql/dbml-error.log +0 -0
- package/__tests__/sql2dbml/multiple_schema_mysql/out-files/multiple_schema.out.dbml +136 -0
- package/__tests__/sql2dbml/multiple_schema_pg/dbml-error.log +0 -0
- package/__tests__/sql2dbml/multiple_schema_pg/out-files/multiple_schema.out.dbml +101 -0
- package/__tests__/sql2dbml/syntax-error/dbml-error.log +6 -0
- package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +6 -0
- package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +6 -0
- package/eslint.config.ts +13 -6
- package/lib/index.js +374 -20
- package/package.json +9 -26
- package/tsconfig.json +2 -1
- package/vite.config.ts +50 -0
- package/.babelrc +0 -19
- package/jest.config.ts +0 -14
- package/lib/cli/config.js +0 -29
- package/lib/cli/connector.js +0 -38
- package/lib/cli/export.js +0 -37
- package/lib/cli/import.js +0 -36
- package/lib/cli/index.js +0 -76
- package/lib/cli/outputPlugins/outputConsolePlugin.js +0 -12
- package/lib/cli/outputPlugins/outputFilePlugin.js +0 -28
- package/lib/cli/utils.js +0 -81
- package/lib/cli/validatePlugins/validatePlugins.js +0 -14
- package/lib/errors/domainError.js +0 -15
- package/lib/errors/index.js +0 -20
- package/lib/errors/syntaxError.js +0 -23
- package/lib/helpers/logger.js +0 -74
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
2026-02-04T14:15:45.582Z
|
|
2
|
+
ConnectionError: Failed to connect to localhost:1433 - Could not connect (sequence)
|
|
3
|
+
at /home/huydna/projects/dbml/packages/dbml-cli/node_modules/mssql/lib/tedious/connection-pool.js:85:17
|
|
4
|
+
at Connection.onConnect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/tedious/lib/connection.js:849:9)
|
|
5
|
+
at Object.onceWrapper (node:events:634:26)
|
|
6
|
+
at Connection.emit (node:events:519:28)
|
|
7
|
+
at Connection.emit (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/tedious/lib/connection.js:970:18)
|
|
8
|
+
at Connection.socketError (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/tedious/lib/connection.js:1353:12)
|
|
9
|
+
at /home/huydna/projects/dbml/packages/dbml-cli/node_modules/tedious/lib/connection.js:1146:14
|
|
10
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
|
|
11
|
+
|
|
12
|
+
2026-02-05T04:34:10.376Z
|
|
13
|
+
ConnectionError: Failed to connect to localhost:1433 - Could not connect (sequence)
|
|
14
|
+
at /home/huydna/projects/dbml/node_modules/mssql/lib/tedious/connection-pool.js:85:17
|
|
15
|
+
at Connection.onConnect (/home/huydna/projects/dbml/node_modules/tedious/lib/connection.js:849:9)
|
|
16
|
+
at Object.onceWrapper (node:events:623:26)
|
|
17
|
+
at Connection.emit (node:events:508:28)
|
|
18
|
+
at Connection.emit (/home/huydna/projects/dbml/node_modules/tedious/lib/connection.js:970:18)
|
|
19
|
+
at Connection.socketError (/home/huydna/projects/dbml/node_modules/tedious/lib/connection.js:1351:12)
|
|
20
|
+
at /home/huydna/projects/dbml/node_modules/tedious/lib/connection.js:1144:14
|
|
21
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:84:11)
|
|
22
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
2026-02-04T14:15:48.138Z
|
|
2
|
+
Error: NJS-503: connection to host 127.0.0.1 port 1521 could not be established. (CONNECTION_ID=S1sNTffPypT0qAXAPeoTrw==)
|
|
3
|
+
connect ECONNREFUSED 127.0.0.1:1521
|
|
4
|
+
at Object.throwErr (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/errors.js:776:10)
|
|
5
|
+
at NTTCP.ntConnect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:206:16)
|
|
6
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
|
|
7
|
+
at async NTTCP.connect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:222:7)
|
|
8
|
+
at async NetworkSession.transportConnect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:182:5)
|
|
9
|
+
at async NetworkSession.connect2 (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:222:7)
|
|
10
|
+
at async NetworkSession.connect1 (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:336:23)
|
|
11
|
+
at async NetworkSession.connect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:623:5)
|
|
12
|
+
at async ThinConnectionImpl.connect (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/thin/connection.js:859:5)
|
|
13
|
+
at async getConnection (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/oracledb/lib/oracledb.js:791:3)
|
|
14
|
+
|
|
15
|
+
2026-02-05T04:34:12.836Z
|
|
16
|
+
Error: NJS-503: connection to host 127.0.0.1 port 1521 could not be established. (CONNECTION_ID=Sg6JqxvL/c5OVskE4Fz+VQ==)
|
|
17
|
+
connect ECONNREFUSED 127.0.0.1:1521
|
|
18
|
+
at Object.throwErr (/home/huydna/projects/dbml/node_modules/oracledb/lib/errors.js:776:10)
|
|
19
|
+
at NTTCP.ntConnect (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:206:16)
|
|
20
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
|
|
21
|
+
at async NTTCP.connect (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:222:7)
|
|
22
|
+
at async NetworkSession.transportConnect (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:182:5)
|
|
23
|
+
at async NetworkSession.connect2 (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:222:7)
|
|
24
|
+
at async NetworkSession.connect1 (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:336:23)
|
|
25
|
+
at async NetworkSession.connect (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:623:5)
|
|
26
|
+
at async ThinConnectionImpl.connect (/home/huydna/projects/dbml/node_modules/oracledb/lib/thin/connection.js:859:5)
|
|
27
|
+
at async getConnection (/home/huydna/projects/dbml/node_modules/oracledb/lib/oracledb.js:791:3)
|
|
28
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
2026-02-04T14:15:49.384Z
|
|
2
|
+
Error: PostgreSQL connection error: AggregateError
|
|
3
|
+
at getValidatedClient (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/@dbml/connector/dist/connectors/postgres/index.js:20:19)
|
|
4
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
|
|
5
|
+
at async fetchSchemaJson (/home/huydna/projects/dbml/packages/dbml-cli/node_modules/@dbml/connector/dist/connectors/postgres/index.js:487:20)
|
|
6
|
+
at async Module.connectionHandler [as default] (/home/huydna/projects/dbml/packages/dbml-cli/lib/cli/connector.js:22:22)
|
|
7
|
+
|
|
8
|
+
2026-02-05T04:34:14.065Z
|
|
9
|
+
Error: PostgreSQL connection error: AggregateError
|
|
10
|
+
at O (/home/huydna/projects/dbml/packages/dbml-connector/dist/index.js:1:1761)
|
|
11
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
|
|
12
|
+
at async N (/home/huydna/projects/dbml/packages/dbml-connector/dist/index.js:218:277)
|
|
13
|
+
at async connectionHandler (/home/huydna/projects/dbml/packages/dbml-cli/lib/index.js:247:22)
|
|
14
|
+
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
-- SQL dump generated using DBML (dbml.dbdiagram.io)
|
|
2
|
+
-- Database: MySQL
|
|
3
|
+
-- Generated at: 2026-02-05T04:33:04.831Z
|
|
4
|
+
|
|
5
|
+
CREATE TABLE `orders` (
|
|
6
|
+
`id` int PRIMARY KEY AUTO_INCREMENT,
|
|
7
|
+
`user_id` int UNIQUE NOT NULL,
|
|
8
|
+
`status` ENUM ('created', 'running', 'done', 'failure'),
|
|
9
|
+
`created_at` varchar(255)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE `order_items` (
|
|
13
|
+
`order_id` int,
|
|
14
|
+
`product_id` int,
|
|
15
|
+
`quantity` int DEFAULT 1
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE TABLE `products` (
|
|
19
|
+
`id` int PRIMARY KEY,
|
|
20
|
+
`name` varchar(255),
|
|
21
|
+
`merchant_id` int NOT NULL,
|
|
22
|
+
`price` int,
|
|
23
|
+
`status` ENUM ('Out of Stock', 'In Stock'),
|
|
24
|
+
`created_at` datetime DEFAULT (now())
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
CREATE TABLE `users` (
|
|
28
|
+
`id` int PRIMARY KEY,
|
|
29
|
+
`full_name` varchar(255),
|
|
30
|
+
`email` varchar(255) UNIQUE,
|
|
31
|
+
`gender` varchar(255),
|
|
32
|
+
`date_of_birth` varchar(255),
|
|
33
|
+
`created_at` varchar(255),
|
|
34
|
+
`country_code` int
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE TABLE `merchants` (
|
|
38
|
+
`id` int PRIMARY KEY,
|
|
39
|
+
`merchant_name` varchar(255),
|
|
40
|
+
`country_code` int,
|
|
41
|
+
`created_at` varchar(255),
|
|
42
|
+
`admin_id` int
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE TABLE `countries` (
|
|
46
|
+
`code` int PRIMARY KEY,
|
|
47
|
+
`name` varchar(255),
|
|
48
|
+
`continent_name` varchar(255)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
CREATE INDEX `product_status` ON `products` (`merchant_id`, `status`);
|
|
52
|
+
|
|
53
|
+
CREATE UNIQUE INDEX `products_index_1` ON `products` (`id`) USING HASH;
|
|
54
|
+
|
|
55
|
+
ALTER TABLE `order_items` ADD FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`);
|
|
56
|
+
|
|
57
|
+
ALTER TABLE `order_items` ADD FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);
|
|
58
|
+
|
|
59
|
+
ALTER TABLE `users` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
|
|
60
|
+
|
|
61
|
+
ALTER TABLE `merchants` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
|
|
62
|
+
|
|
63
|
+
ALTER TABLE `products` ADD FOREIGN KEY (`merchant_id`) REFERENCES `merchants` (`id`);
|
|
64
|
+
|
|
65
|
+
ALTER TABLE `merchants` ADD FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`);
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
-- SQL dump generated using DBML (dbml.dbdiagram.io)
|
|
2
|
+
-- Database: Oracle
|
|
3
|
+
-- Generated at: 2026-02-05T04:33:07.189Z
|
|
4
|
+
|
|
5
|
+
CREATE TABLE "orders" (
|
|
6
|
+
"id" int GENERATED AS IDENTITY PRIMARY KEY,
|
|
7
|
+
"user_id" int UNIQUE NOT NULL,
|
|
8
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('created', 'running', 'done', 'failure'))
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
CREATE TABLE "order_items" (
|
|
12
|
+
"order_id" int,
|
|
13
|
+
"product_id" int,
|
|
14
|
+
"quantity" int DEFAULT 1
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE "products" (
|
|
18
|
+
"id" int PRIMARY KEY,
|
|
19
|
+
"name" nvarchar2(255),
|
|
20
|
+
"merchant_id" int NOT NULL,
|
|
21
|
+
"price" int,
|
|
22
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('Out of Stock', 'In Stock')),
|
|
23
|
+
"created_at" timestamp DEFAULT current_timestamp
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE TABLE "users" (
|
|
27
|
+
"id" int PRIMARY KEY,
|
|
28
|
+
"full_name" nvarchar2(255),
|
|
29
|
+
"email" nvarchar2(255) UNIQUE,
|
|
30
|
+
"gender" nvarchar2(255),
|
|
31
|
+
"date_of_birth" date,
|
|
32
|
+
"created_at" timestamp,
|
|
33
|
+
"country_code" int
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE TABLE "merchants" (
|
|
37
|
+
"id" int PRIMARY KEY,
|
|
38
|
+
"merchant_name" nvarchar2(255),
|
|
39
|
+
"country_code" int,
|
|
40
|
+
"created_at" timestamp,
|
|
41
|
+
"admin_id" int
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE TABLE "countries" (
|
|
45
|
+
"code" int PRIMARY KEY,
|
|
46
|
+
"name" nvarchar2(255)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
|
|
50
|
+
|
|
51
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
|
|
52
|
+
|
|
53
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
|
|
54
|
+
|
|
55
|
+
ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
56
|
+
|
|
57
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
58
|
+
|
|
59
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
|
|
60
|
+
|
|
61
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
-- SQL dump generated using DBML (dbml.dbdiagram.io)
|
|
2
|
+
-- Database: PostgreSQL
|
|
3
|
+
-- Generated at: 2026-02-05T04:33:09.544Z
|
|
4
|
+
|
|
5
|
+
CREATE TYPE "orders_status" AS ENUM (
|
|
6
|
+
'created',
|
|
7
|
+
'running',
|
|
8
|
+
'done',
|
|
9
|
+
'failure'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TYPE "product status" AS ENUM (
|
|
13
|
+
'Out of Stock',
|
|
14
|
+
'In Stock'
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE "orders" (
|
|
18
|
+
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
19
|
+
"user_id" int UNIQUE NOT NULL,
|
|
20
|
+
"status" orders_status,
|
|
21
|
+
"created_at" varchar
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE TABLE "order_items" (
|
|
25
|
+
"order_id" int,
|
|
26
|
+
"product_id" int,
|
|
27
|
+
"quantity" int DEFAULT 1
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE "products" (
|
|
31
|
+
"id" int PRIMARY KEY,
|
|
32
|
+
"name" varchar,
|
|
33
|
+
"merchant_id" int NOT NULL,
|
|
34
|
+
"price" int,
|
|
35
|
+
"status" "product status",
|
|
36
|
+
"created_at" datetime DEFAULT (now())
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE TABLE "users" (
|
|
40
|
+
"id" int PRIMARY KEY,
|
|
41
|
+
"full_name" varchar,
|
|
42
|
+
"email" varchar UNIQUE,
|
|
43
|
+
"gender" varchar,
|
|
44
|
+
"date_of_birth" varchar,
|
|
45
|
+
"created_at" varchar,
|
|
46
|
+
"country_code" int
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
CREATE TABLE "merchants" (
|
|
50
|
+
"id" int PRIMARY KEY,
|
|
51
|
+
"merchant_name" varchar,
|
|
52
|
+
"country_code" int,
|
|
53
|
+
"created_at" varchar,
|
|
54
|
+
"admin_id" int
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE TABLE "countries" (
|
|
58
|
+
"code" int PRIMARY KEY,
|
|
59
|
+
"name" varchar,
|
|
60
|
+
"continent_name" varchar
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
|
|
64
|
+
|
|
65
|
+
CREATE UNIQUE INDEX ON "products" USING HASH ("id");
|
|
66
|
+
|
|
67
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
|
|
68
|
+
|
|
69
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
|
|
70
|
+
|
|
71
|
+
ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
72
|
+
|
|
73
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
74
|
+
|
|
75
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
|
|
76
|
+
|
|
77
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
-- SQL dump generated using DBML (dbml.dbdiagram.io)
|
|
2
|
+
-- Database: PostgreSQL
|
|
3
|
+
-- Generated at: 2026-02-05T04:33:10.708Z
|
|
4
|
+
|
|
5
|
+
CREATE TYPE "orders_status" AS ENUM (
|
|
6
|
+
'created',
|
|
7
|
+
'running',
|
|
8
|
+
'done',
|
|
9
|
+
'failure'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TYPE "product status" AS ENUM (
|
|
13
|
+
'Out of Stock',
|
|
14
|
+
'In Stock'
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE "orders" (
|
|
18
|
+
"id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
19
|
+
"user_id" int UNIQUE NOT NULL,
|
|
20
|
+
"status" orders_status,
|
|
21
|
+
"created_at" varchar
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE TABLE "order_items" (
|
|
25
|
+
"order_id" int,
|
|
26
|
+
"product_id" int,
|
|
27
|
+
"quantity" int DEFAULT 1
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE "products" (
|
|
31
|
+
"id" int PRIMARY KEY,
|
|
32
|
+
"name" varchar,
|
|
33
|
+
"merchant_id" int NOT NULL,
|
|
34
|
+
"price" int,
|
|
35
|
+
"status" "product status",
|
|
36
|
+
"created_at" datetime DEFAULT (now())
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE TABLE "users" (
|
|
40
|
+
"id" int PRIMARY KEY,
|
|
41
|
+
"full_name" varchar,
|
|
42
|
+
"email" varchar UNIQUE,
|
|
43
|
+
"gender" varchar,
|
|
44
|
+
"date_of_birth" varchar,
|
|
45
|
+
"created_at" varchar,
|
|
46
|
+
"country_code" int
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
CREATE TABLE "merchants" (
|
|
50
|
+
"id" int PRIMARY KEY,
|
|
51
|
+
"merchant_name" varchar,
|
|
52
|
+
"country_code" int,
|
|
53
|
+
"created_at" varchar,
|
|
54
|
+
"admin_id" int
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE TABLE "countries" (
|
|
58
|
+
"code" int PRIMARY KEY,
|
|
59
|
+
"name" varchar,
|
|
60
|
+
"continent_name" varchar
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
|
|
64
|
+
|
|
65
|
+
CREATE UNIQUE INDEX ON "products" USING HASH ("id");
|
|
66
|
+
|
|
67
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
|
|
68
|
+
|
|
69
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
|
|
70
|
+
|
|
71
|
+
ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
72
|
+
|
|
73
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
74
|
+
|
|
75
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
|
|
76
|
+
|
|
77
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
-- SQL dump generated using DBML (dbml.dbdiagram.io)
|
|
2
|
+
-- Database: MySQL
|
|
3
|
+
-- Generated at: 2026-02-05T04:33:14.192Z
|
|
4
|
+
|
|
5
|
+
CREATE TABLE `staff` (
|
|
6
|
+
`id` int PRIMARY KEY,
|
|
7
|
+
`first_name` varchar(255),
|
|
8
|
+
`last_name` varchar(255),
|
|
9
|
+
`address_id` int,
|
|
10
|
+
`picture` blob,
|
|
11
|
+
`email` varchar(255),
|
|
12
|
+
`store_id` int,
|
|
13
|
+
`active` boolean,
|
|
14
|
+
`user_name` varchar(255),
|
|
15
|
+
`password` varchar(255),
|
|
16
|
+
`last_update` timestamp
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE `store` (
|
|
20
|
+
`id` int PRIMARY KEY,
|
|
21
|
+
`manager_staff_id` int,
|
|
22
|
+
`address_id` int,
|
|
23
|
+
`last_update` timestamp
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE TABLE `payment` (
|
|
27
|
+
`id` int PRIMARY KEY,
|
|
28
|
+
`customer_id` int,
|
|
29
|
+
`staff_id` int,
|
|
30
|
+
`rental_id` int,
|
|
31
|
+
`amount` decimal,
|
|
32
|
+
`payment_date` datetime,
|
|
33
|
+
`last_update` timestamp
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE TABLE `rental` (
|
|
37
|
+
`id` int PRIMARY KEY,
|
|
38
|
+
`rental_date` datetime,
|
|
39
|
+
`inventory_id` int,
|
|
40
|
+
`customer_id` int,
|
|
41
|
+
`return_date` ddatetime,
|
|
42
|
+
`staff_id` int,
|
|
43
|
+
`last_update` timestamp
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
ALTER TABLE `staff` ADD FOREIGN KEY (`store_id`) REFERENCES `store` (`id`);
|
|
47
|
+
|
|
48
|
+
ALTER TABLE `store` ADD FOREIGN KEY (`manager_staff_id`) REFERENCES `staff` (`id`);
|
|
49
|
+
|
|
50
|
+
ALTER TABLE `payment` ADD FOREIGN KEY (`staff_id`) REFERENCES `staff` (`id`);
|
|
51
|
+
|
|
52
|
+
ALTER TABLE `payment` ADD FOREIGN KEY (`rental_id`) REFERENCES `rental` (`id`);
|
|
53
|
+
|
|
54
|
+
ALTER TABLE `rental` ADD FOREIGN KEY (`staff_id`) REFERENCES `staff` (`id`);
|
|
55
|
+
CREATE TABLE `country` (
|
|
56
|
+
`id` int PRIMARY KEY,
|
|
57
|
+
`country` varchar(255),
|
|
58
|
+
`last_update` timestamp
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
CREATE TABLE `city` (
|
|
62
|
+
`id` int PRIMARY KEY,
|
|
63
|
+
`city` varchar(255),
|
|
64
|
+
`country_id` int,
|
|
65
|
+
`last_update` timestamp
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
CREATE TABLE `address` (
|
|
69
|
+
`id` int PRIMARY KEY,
|
|
70
|
+
`address` varchar(255),
|
|
71
|
+
`address2` varchar(255),
|
|
72
|
+
`district` varchar(255),
|
|
73
|
+
`city_id` int,
|
|
74
|
+
`postal_code` varchar(255),
|
|
75
|
+
`phone` varchar(255),
|
|
76
|
+
`last_update` timestamp
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
CREATE TABLE `customer` (
|
|
80
|
+
`id` int PRIMARY KEY,
|
|
81
|
+
`store_id` int,
|
|
82
|
+
`first_name` varchar(255),
|
|
83
|
+
`last_name` varchar(255),
|
|
84
|
+
`email` varchar(255),
|
|
85
|
+
`address_id` int,
|
|
86
|
+
`active` boolean,
|
|
87
|
+
`create_Date` timestamp,
|
|
88
|
+
`last_update` timestamp
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
CREATE INDEX `customer_index_0` ON `customer` (`id`, `first_name`) USING BTREE;
|
|
92
|
+
|
|
93
|
+
ALTER TABLE `city` ADD FOREIGN KEY (`country_id`) REFERENCES `country` (`id`);
|
|
94
|
+
|
|
95
|
+
ALTER TABLE `address` ADD FOREIGN KEY (`city_id`) REFERENCES `city` (`id`);
|
|
96
|
+
|
|
97
|
+
ALTER TABLE `customer` ADD FOREIGN KEY (`address_id`) REFERENCES `address` (`id`);
|
|
98
|
+
CREATE TABLE `category` (
|
|
99
|
+
`id` int PRIMARY KEY,
|
|
100
|
+
`name` varchar(255),
|
|
101
|
+
`last_update` timestamp
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
CREATE TABLE `film_category` (
|
|
105
|
+
`id` int PRIMARY KEY,
|
|
106
|
+
`category_id` int,
|
|
107
|
+
`last_update` timestamp
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
CREATE TABLE `language` (
|
|
111
|
+
`id` int PRIMARY KEY,
|
|
112
|
+
`name` varchar(255),
|
|
113
|
+
`last_update` timestamp
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
CREATE TABLE `film_text` (
|
|
117
|
+
`id` int PRIMARY KEY,
|
|
118
|
+
`film_id` int,
|
|
119
|
+
`title` varchar(255),
|
|
120
|
+
`description` text
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
CREATE TABLE `actor` (
|
|
124
|
+
`id` int PRIMARY KEY,
|
|
125
|
+
`first_name` varchar(255),
|
|
126
|
+
`last_name` varchar(255),
|
|
127
|
+
`last_update` timestamp
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
CREATE TABLE `film` (
|
|
131
|
+
`id` int PRIMARY KEY,
|
|
132
|
+
`title` varchar(255),
|
|
133
|
+
`description` text,
|
|
134
|
+
`releaase_year` int,
|
|
135
|
+
`language_id` int,
|
|
136
|
+
`original_language_id` int,
|
|
137
|
+
`rental_duration` int,
|
|
138
|
+
`rental_rate` decimal,
|
|
139
|
+
`length` int,
|
|
140
|
+
`replacement_cost` decimal,
|
|
141
|
+
`rating` varchar(255),
|
|
142
|
+
`special_feature` varchar(255),
|
|
143
|
+
`last_update` timestamp
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
CREATE TABLE `film_actor` (
|
|
147
|
+
`id` int PRIMARY KEY,
|
|
148
|
+
`film_id` int,
|
|
149
|
+
`actor_id` int,
|
|
150
|
+
`last_update` timestamp
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
CREATE TABLE `inventory` (
|
|
154
|
+
`id` int PRIMARY KEY,
|
|
155
|
+
`film_id` int,
|
|
156
|
+
`store_id` int,
|
|
157
|
+
`last_update` timestamp
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
ALTER TABLE `film_category` ADD FOREIGN KEY (`category_id`) REFERENCES `category` (`id`);
|
|
161
|
+
|
|
162
|
+
ALTER TABLE `film_text` ADD FOREIGN KEY (`film_id`) REFERENCES `inventory` (`film_id`);
|
|
163
|
+
|
|
164
|
+
ALTER TABLE `film` ADD FOREIGN KEY (`language_id`) REFERENCES `language` (`id`);
|
|
165
|
+
|
|
166
|
+
ALTER TABLE `film` ADD FOREIGN KEY (`original_language_id`) REFERENCES `language` (`id`);
|
|
167
|
+
|
|
168
|
+
ALTER TABLE `film_actor` ADD FOREIGN KEY (`film_id`) REFERENCES `film` (`id`);
|
|
169
|
+
|
|
170
|
+
ALTER TABLE `film_actor` ADD FOREIGN KEY (`actor_id`) REFERENCES `actor` (`id`);
|
|
171
|
+
|
|
172
|
+
ALTER TABLE `inventory` ADD FOREIGN KEY (`film_id`) REFERENCES `film` (`id`);
|
|
File without changes
|
|
File without changes
|