@dbml/cli 3.3.0 → 3.4.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__/dbml2sql/filename --oracle --out-file/expect-out-files/schema.sql +57 -0
- package/__test__/dbml2sql/filename --oracle --out-file/in-files/schema.dbml +71 -0
- package/__test__/dbml2sql/filename --oracle --out-file/options.json +8 -0
- package/__test__/dbml2sql/filename --oracle --out-file/stdout.txt +1 -0
- package/__test__/dbml2sql/filename --oracle stdout/in-files/schema.dbml +71 -0
- package/__test__/dbml2sql/filename --oracle stdout/options.json +6 -0
- package/__test__/dbml2sql/filename --oracle stdout/stdout.txt +58 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/expect-out-files/schema.sql +168 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/in-files/business.dbml +40 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/in-files/customer.dbml +39 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/in-files/inventory.dbml +61 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/options.json +10 -0
- package/__test__/dbml2sql/filenames --oracle --out-file/stdout.txt +1 -0
- package/__test__/dbml2sql/filenames --oracle stdout/in-files/business.dbml +40 -0
- package/__test__/dbml2sql/filenames --oracle stdout/in-files/customer.dbml +39 -0
- package/__test__/dbml2sql/filenames --oracle stdout/in-files/inventory.dbml +61 -0
- package/__test__/dbml2sql/filenames --oracle stdout/options.json +8 -0
- package/__test__/dbml2sql/filenames --oracle stdout/stdout.txt +171 -0
- package/__test__/dbml2sql/multiple_schema_oracle/expect-out-files/multiple_schema.out.sql +84 -0
- package/__test__/dbml2sql/multiple_schema_oracle/in-files/multiple_schema.in.dbml +45 -0
- package/__test__/dbml2sql/multiple_schema_oracle/options.json +8 -0
- package/__test__/dbml2sql/multiple_schema_oracle/stdout.txt +1 -0
- package/lib/cli/config.js +3 -0
- package/lib/cli/export.js +2 -1
- package/lib/cli/index.js +1 -1
- package/lib/cli/utils.js +1 -1
- package/package.json +3 -3
- package/src/cli/config.js +3 -0
- package/src/cli/export.js +7 -3
- package/src/cli/index.js +1 -0
- package/src/cli/utils.js +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
CREATE TABLE "orders" (
|
|
2
|
+
"id" int GENERATED AS IDENTITY PRIMARY KEY,
|
|
3
|
+
"user_id" int UNIQUE NOT NULL,
|
|
4
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('created', 'running', 'done', 'failure'))
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
CREATE TABLE "order_items" (
|
|
8
|
+
"order_id" int,
|
|
9
|
+
"product_id" int,
|
|
10
|
+
"quantity" int DEFAULT 1
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CREATE TABLE "products" (
|
|
14
|
+
"id" int PRIMARY KEY,
|
|
15
|
+
"name" nvarchar2(255),
|
|
16
|
+
"merchant_id" int NOT NULL,
|
|
17
|
+
"price" int,
|
|
18
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('Out of Stock', 'In Stock')),
|
|
19
|
+
"created_at" timestamp DEFAULT current_timestamp
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE "users" (
|
|
23
|
+
"id" int PRIMARY KEY,
|
|
24
|
+
"full_name" nvarchar2(255),
|
|
25
|
+
"email" nvarchar2(255) UNIQUE,
|
|
26
|
+
"gender" nvarchar2(255),
|
|
27
|
+
"date_of_birth" date,
|
|
28
|
+
"created_at" timestamp,
|
|
29
|
+
"country_code" int
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE TABLE "merchants" (
|
|
33
|
+
"id" int PRIMARY KEY,
|
|
34
|
+
"merchant_name" nvarchar2(255),
|
|
35
|
+
"country_code" int,
|
|
36
|
+
"created_at" timestamp,
|
|
37
|
+
"admin_id" int
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE "countries" (
|
|
41
|
+
"code" int PRIMARY KEY,
|
|
42
|
+
"name" nvarchar2(255)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
|
|
46
|
+
|
|
47
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
|
|
48
|
+
|
|
49
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
|
|
50
|
+
|
|
51
|
+
ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
52
|
+
|
|
53
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
54
|
+
|
|
55
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
|
|
56
|
+
|
|
57
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
|
|
@@ -0,0 +1,71 @@
|
|
|
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" int [pk, increment]
|
|
15
|
+
"user_id" int [unique, not null]
|
|
16
|
+
"status" orders_status
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Table "order_items" {
|
|
20
|
+
"order_id" int
|
|
21
|
+
"product_id" int
|
|
22
|
+
"quantity" int [default: 1]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Table "products" {
|
|
26
|
+
"id" int [pk]
|
|
27
|
+
"name" nvarchar2(255)
|
|
28
|
+
"merchant_id" int [not null]
|
|
29
|
+
"price" int
|
|
30
|
+
"status" "product status"
|
|
31
|
+
"created_at" timestamp [default: `current_timestamp`]
|
|
32
|
+
|
|
33
|
+
Indexes {
|
|
34
|
+
(merchant_id, status) [name: "product_status"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Table "users" {
|
|
39
|
+
"id" int [pk]
|
|
40
|
+
"full_name" nvarchar2(255)
|
|
41
|
+
"email" nvarchar2(255) [unique]
|
|
42
|
+
"gender" nvarchar2(255)
|
|
43
|
+
"date_of_birth" date
|
|
44
|
+
"created_at" timestamp
|
|
45
|
+
"country_code" int
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Table "merchants" {
|
|
49
|
+
"id" int [pk]
|
|
50
|
+
"merchant_name" nvarchar2(255)
|
|
51
|
+
"country_code" int
|
|
52
|
+
"created_at" timestamp
|
|
53
|
+
"admin_id" int
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Table "countries" {
|
|
57
|
+
"code" int [pk]
|
|
58
|
+
"name" nvarchar2(255)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Ref:"orders"."id" < "order_items"."order_id"
|
|
62
|
+
|
|
63
|
+
Ref:"products"."id" < "order_items"."product_id"
|
|
64
|
+
|
|
65
|
+
Ref:"countries"."code" < "users"."country_code"
|
|
66
|
+
|
|
67
|
+
Ref:"countries"."code" < "merchants"."country_code"
|
|
68
|
+
|
|
69
|
+
Ref:"merchants"."id" < "products"."merchant_id"
|
|
70
|
+
|
|
71
|
+
Ref:"users"."id" < "merchants"."admin_id"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
✔ Generated SQL dump file (Oracle): schema.sql
|
|
@@ -0,0 +1,71 @@
|
|
|
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" int [pk, increment]
|
|
15
|
+
"user_id" int [unique, not null]
|
|
16
|
+
"status" orders_status
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Table "order_items" {
|
|
20
|
+
"order_id" int
|
|
21
|
+
"product_id" int
|
|
22
|
+
"quantity" int [default: 1]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Table "products" {
|
|
26
|
+
"id" int [pk]
|
|
27
|
+
"name" nvarchar2(255)
|
|
28
|
+
"merchant_id" int [not null]
|
|
29
|
+
"price" int
|
|
30
|
+
"status" "product status"
|
|
31
|
+
"created_at" timestamp [default: `current_timestamp`]
|
|
32
|
+
|
|
33
|
+
Indexes {
|
|
34
|
+
(merchant_id, status) [name: "product_status"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Table "users" {
|
|
39
|
+
"id" int [pk]
|
|
40
|
+
"full_name" nvarchar2(255)
|
|
41
|
+
"email" nvarchar2(255) [unique]
|
|
42
|
+
"gender" nvarchar2(255)
|
|
43
|
+
"date_of_birth" date
|
|
44
|
+
"created_at" timestamp
|
|
45
|
+
"country_code" int
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Table "merchants" {
|
|
49
|
+
"id" int [pk]
|
|
50
|
+
"merchant_name" nvarchar2(255)
|
|
51
|
+
"country_code" int
|
|
52
|
+
"created_at" timestamp
|
|
53
|
+
"admin_id" int
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Table "countries" {
|
|
57
|
+
"code" int [pk]
|
|
58
|
+
"name" nvarchar2(255)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Ref:"orders"."id" < "order_items"."order_id"
|
|
62
|
+
|
|
63
|
+
Ref:"products"."id" < "order_items"."product_id"
|
|
64
|
+
|
|
65
|
+
Ref:"countries"."code" < "users"."country_code"
|
|
66
|
+
|
|
67
|
+
Ref:"countries"."code" < "merchants"."country_code"
|
|
68
|
+
|
|
69
|
+
Ref:"merchants"."id" < "products"."merchant_id"
|
|
70
|
+
|
|
71
|
+
Ref:"users"."id" < "merchants"."admin_id"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
CREATE TABLE "orders" (
|
|
2
|
+
"id" int GENERATED AS IDENTITY PRIMARY KEY,
|
|
3
|
+
"user_id" int UNIQUE NOT NULL,
|
|
4
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('created', 'running', 'done', 'failure'))
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
CREATE TABLE "order_items" (
|
|
8
|
+
"order_id" int,
|
|
9
|
+
"product_id" int,
|
|
10
|
+
"quantity" int DEFAULT 1
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CREATE TABLE "products" (
|
|
14
|
+
"id" int PRIMARY KEY,
|
|
15
|
+
"name" nvarchar2(255),
|
|
16
|
+
"merchant_id" int NOT NULL,
|
|
17
|
+
"price" int,
|
|
18
|
+
"status" nvarchar2(255) NOT NULL CHECK ("status" IN ('Out of Stock', 'In Stock')),
|
|
19
|
+
"created_at" timestamp DEFAULT current_timestamp
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE "users" (
|
|
23
|
+
"id" int PRIMARY KEY,
|
|
24
|
+
"full_name" nvarchar2(255),
|
|
25
|
+
"email" nvarchar2(255) UNIQUE,
|
|
26
|
+
"gender" nvarchar2(255),
|
|
27
|
+
"date_of_birth" date,
|
|
28
|
+
"created_at" timestamp,
|
|
29
|
+
"country_code" int
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE TABLE "merchants" (
|
|
33
|
+
"id" int PRIMARY KEY,
|
|
34
|
+
"merchant_name" nvarchar2(255),
|
|
35
|
+
"country_code" int,
|
|
36
|
+
"created_at" timestamp,
|
|
37
|
+
"admin_id" int
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE "countries" (
|
|
41
|
+
"code" int PRIMARY KEY,
|
|
42
|
+
"name" nvarchar2(255)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
|
|
46
|
+
|
|
47
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
|
|
48
|
+
|
|
49
|
+
ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
|
|
50
|
+
|
|
51
|
+
ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
52
|
+
|
|
53
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
|
|
54
|
+
|
|
55
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
|
|
56
|
+
|
|
57
|
+
ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
|
|
58
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
CREATE TABLE "staff" (
|
|
2
|
+
"id" int PRIMARY KEY,
|
|
3
|
+
"first_name" nvarchar2(255),
|
|
4
|
+
"last_name" nvarchar2(255),
|
|
5
|
+
"address_id" int,
|
|
6
|
+
"picture" blob,
|
|
7
|
+
"email" nvarchar2(255),
|
|
8
|
+
"store_id" int,
|
|
9
|
+
"active" number(1),
|
|
10
|
+
"user_name" nvarchar2(255),
|
|
11
|
+
"password" nvarchar2(255),
|
|
12
|
+
"last_update" timestamp
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE "store" (
|
|
16
|
+
"id" int PRIMARY KEY,
|
|
17
|
+
"manager_staff_id" int,
|
|
18
|
+
"address_id" int,
|
|
19
|
+
"last_update" timestamp
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE "payment" (
|
|
23
|
+
"id" int PRIMARY KEY,
|
|
24
|
+
"customer_id" int,
|
|
25
|
+
"staff_id" int,
|
|
26
|
+
"rental_id" int,
|
|
27
|
+
"amount" float,
|
|
28
|
+
"payment_date" date,
|
|
29
|
+
"last_update" timestamp
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE TABLE "rental" (
|
|
33
|
+
"id" int PRIMARY KEY,
|
|
34
|
+
"rental_date" date,
|
|
35
|
+
"inventory_id" int,
|
|
36
|
+
"customer_id" int,
|
|
37
|
+
"return_date" date,
|
|
38
|
+
"staff_id" int,
|
|
39
|
+
"last_update" timestamp
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
ALTER TABLE "staff" ADD FOREIGN KEY ("store_id") REFERENCES "store" ("id");
|
|
43
|
+
|
|
44
|
+
ALTER TABLE "store" ADD FOREIGN KEY ("manager_staff_id") REFERENCES "staff" ("id");
|
|
45
|
+
|
|
46
|
+
ALTER TABLE "payment" ADD FOREIGN KEY ("staff_id") REFERENCES "staff" ("id");
|
|
47
|
+
|
|
48
|
+
ALTER TABLE "payment" ADD FOREIGN KEY ("rental_id") REFERENCES "rental" ("id");
|
|
49
|
+
|
|
50
|
+
ALTER TABLE "rental" ADD FOREIGN KEY ("staff_id") REFERENCES "staff" ("id");
|
|
51
|
+
CREATE TABLE "country" (
|
|
52
|
+
"id" int PRIMARY KEY,
|
|
53
|
+
"country" nvarchar2(255),
|
|
54
|
+
"last_update" timestamp
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
CREATE TABLE "city" (
|
|
58
|
+
"id" int PRIMARY KEY,
|
|
59
|
+
"city" nvarchar2(255),
|
|
60
|
+
"country_id" int,
|
|
61
|
+
"last_update" timestamp
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
CREATE TABLE "address" (
|
|
65
|
+
"id" int PRIMARY KEY,
|
|
66
|
+
"address" nvarchar2(255),
|
|
67
|
+
"address2" nvarchar2(255),
|
|
68
|
+
"district" nvarchar2(255),
|
|
69
|
+
"city_id" int,
|
|
70
|
+
"postal_code" nvarchar2(255),
|
|
71
|
+
"phone" nvarchar2(255),
|
|
72
|
+
"last_update" timestamp
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
CREATE TABLE "customer" (
|
|
76
|
+
"id" int PRIMARY KEY,
|
|
77
|
+
"store_id" int,
|
|
78
|
+
"first_name" nvarchar2(255),
|
|
79
|
+
"last_name" nvarchar2(255),
|
|
80
|
+
"email" nvarchar2(255),
|
|
81
|
+
"address_id" int,
|
|
82
|
+
"active" number(1),
|
|
83
|
+
"create_Date" timestamp,
|
|
84
|
+
"last_update" timestamp
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
CREATE INDEX "IDX_CUSTOMER" ON "customer" ("id", "first_name");
|
|
88
|
+
|
|
89
|
+
ALTER TABLE "city" ADD FOREIGN KEY ("country_id") REFERENCES "country" ("id");
|
|
90
|
+
|
|
91
|
+
ALTER TABLE "address" ADD FOREIGN KEY ("city_id") REFERENCES "city" ("id");
|
|
92
|
+
|
|
93
|
+
ALTER TABLE "customer" ADD FOREIGN KEY ("address_id") REFERENCES "address" ("id");
|
|
94
|
+
CREATE TABLE "category" (
|
|
95
|
+
"id" int PRIMARY KEY,
|
|
96
|
+
"name" nvarchar2(255),
|
|
97
|
+
"last_update" timestamp
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
CREATE TABLE "film_category" (
|
|
101
|
+
"id" int PRIMARY KEY,
|
|
102
|
+
"category_id" int,
|
|
103
|
+
"last_update" timestamp
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
CREATE TABLE "language" (
|
|
107
|
+
"id" int PRIMARY KEY,
|
|
108
|
+
"name" nvarchar2(255),
|
|
109
|
+
"last_update" timestamp
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
CREATE TABLE "film_text" (
|
|
113
|
+
"id" int PRIMARY KEY,
|
|
114
|
+
"film_id" int,
|
|
115
|
+
"title" nvarchar2(255),
|
|
116
|
+
"description" nclob
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
CREATE TABLE "actor" (
|
|
120
|
+
"id" int PRIMARY KEY,
|
|
121
|
+
"first_name" nvarchar2(255),
|
|
122
|
+
"last_name" nvarchar2(255),
|
|
123
|
+
"last_update" timestamp
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
CREATE TABLE "film" (
|
|
127
|
+
"id" int PRIMARY KEY,
|
|
128
|
+
"title" nvarchar2(255),
|
|
129
|
+
"description" nclob,
|
|
130
|
+
"releaase_year" int,
|
|
131
|
+
"language_id" int,
|
|
132
|
+
"original_language_id" int,
|
|
133
|
+
"rental_duration" int,
|
|
134
|
+
"rental_rate" float,
|
|
135
|
+
"length" int,
|
|
136
|
+
"replacement_cost" float,
|
|
137
|
+
"rating" nvarchar2(255),
|
|
138
|
+
"special_feature" nvarchar2(255),
|
|
139
|
+
"last_update" timestamp
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
CREATE TABLE "film_actor" (
|
|
143
|
+
"id" int PRIMARY KEY,
|
|
144
|
+
"film_id" int,
|
|
145
|
+
"actor_id" int,
|
|
146
|
+
"last_update" timestamp
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
CREATE TABLE "inventory" (
|
|
150
|
+
"id" int PRIMARY KEY,
|
|
151
|
+
"film_id" int,
|
|
152
|
+
"store_id" int,
|
|
153
|
+
"last_update" timestamp
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
ALTER TABLE "film_category" ADD FOREIGN KEY ("category_id") REFERENCES "category" ("id");
|
|
157
|
+
|
|
158
|
+
ALTER TABLE "film_text" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
159
|
+
|
|
160
|
+
ALTER TABLE "film" ADD FOREIGN KEY ("language_id") REFERENCES "language" ("id");
|
|
161
|
+
|
|
162
|
+
ALTER TABLE "film" ADD FOREIGN KEY ("original_language_id") REFERENCES "language" ("id");
|
|
163
|
+
|
|
164
|
+
ALTER TABLE "film_actor" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
165
|
+
|
|
166
|
+
ALTER TABLE "film_actor" ADD FOREIGN KEY ("actor_id") REFERENCES "actor" ("id");
|
|
167
|
+
|
|
168
|
+
ALTER TABLE "inventory" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Table staff {
|
|
2
|
+
id int [pk]
|
|
3
|
+
first_name nvarchar2(255)
|
|
4
|
+
last_name nvarchar2(255)
|
|
5
|
+
address_id int
|
|
6
|
+
picture blob
|
|
7
|
+
email nvarchar2(255)
|
|
8
|
+
store_id int [ref: > store.id]
|
|
9
|
+
active number(1)
|
|
10
|
+
user_name nvarchar2(255)
|
|
11
|
+
password nvarchar2(255)
|
|
12
|
+
last_update timestamp
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Table store {
|
|
16
|
+
id int [pk]
|
|
17
|
+
manager_staff_id int [ref: > staff.id]
|
|
18
|
+
address_id int
|
|
19
|
+
last_update timestamp
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
table payment {
|
|
23
|
+
id int [pk]
|
|
24
|
+
customer_id int
|
|
25
|
+
staff_id int [ref: > staff.id]
|
|
26
|
+
rental_id int [ref: > rental.id]
|
|
27
|
+
amount float
|
|
28
|
+
payment_date date
|
|
29
|
+
last_update timestamp
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Table rental {
|
|
33
|
+
id int [pk]
|
|
34
|
+
rental_date date
|
|
35
|
+
inventory_id int
|
|
36
|
+
customer_id int
|
|
37
|
+
return_date date
|
|
38
|
+
staff_id int [ref: > staff.id]
|
|
39
|
+
last_update timestamp
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Table country {
|
|
2
|
+
id int [pk]
|
|
3
|
+
country nvarchar2(255)
|
|
4
|
+
last_update timestamp
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Table city {
|
|
8
|
+
id int [pk]
|
|
9
|
+
city nvarchar2(255)
|
|
10
|
+
country_id int [ref: > country.id]
|
|
11
|
+
last_update timestamp
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Table address {
|
|
15
|
+
id int [pk]
|
|
16
|
+
address nvarchar2(255)
|
|
17
|
+
address2 nvarchar2(255)
|
|
18
|
+
district nvarchar2(255)
|
|
19
|
+
city_id int [ref: > city.id]
|
|
20
|
+
postal_code nvarchar2(255)
|
|
21
|
+
phone nvarchar2(255)
|
|
22
|
+
last_update timestamp
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Table customer {
|
|
26
|
+
id int [pk]
|
|
27
|
+
store_id int
|
|
28
|
+
first_name nvarchar2(255)
|
|
29
|
+
last_name nvarchar2(255)
|
|
30
|
+
email nvarchar2(255)
|
|
31
|
+
address_id int [ref: > address.id]
|
|
32
|
+
active number(1)
|
|
33
|
+
create_Date timestamp
|
|
34
|
+
last_update timestamp
|
|
35
|
+
|
|
36
|
+
Indexes {
|
|
37
|
+
(id, first_name) [type: btree, name: "IDX_CUSTOMER"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Table category {
|
|
2
|
+
id int [pk]
|
|
3
|
+
name nvarchar2(255)
|
|
4
|
+
last_update timestamp
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Table film_category {
|
|
8
|
+
id int [pk]
|
|
9
|
+
category_id int [ref: > category.id]
|
|
10
|
+
last_update timestamp
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Table language {
|
|
14
|
+
id int [pk]
|
|
15
|
+
name nvarchar2(255)
|
|
16
|
+
last_update timestamp
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Table film_text {
|
|
20
|
+
id int [pk]
|
|
21
|
+
film_id int [ref: > film.id]
|
|
22
|
+
title nvarchar2(255)
|
|
23
|
+
description nclob
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Table actor {
|
|
27
|
+
id int [pk]
|
|
28
|
+
first_name nvarchar2(255)
|
|
29
|
+
last_name nvarchar2(255)
|
|
30
|
+
last_update timestamp
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Table film {
|
|
34
|
+
id int [pk]
|
|
35
|
+
title nvarchar2(255)
|
|
36
|
+
description nclob
|
|
37
|
+
releaase_year int
|
|
38
|
+
language_id int [ref: > language.id]
|
|
39
|
+
original_language_id int [ref: > language.id]
|
|
40
|
+
rental_duration int
|
|
41
|
+
rental_rate float
|
|
42
|
+
length int
|
|
43
|
+
replacement_cost float
|
|
44
|
+
rating nvarchar2(255)
|
|
45
|
+
special_feature nvarchar2(255)
|
|
46
|
+
last_update timestamp
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Table film_actor {
|
|
50
|
+
id int [pk]
|
|
51
|
+
film_id int [ref: > film.id]
|
|
52
|
+
actor_id int [ref: > actor.id]
|
|
53
|
+
last_update timestamp
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Table inventory {
|
|
57
|
+
id int [pk]
|
|
58
|
+
film_id int [ref: > film.id]
|
|
59
|
+
store_id int
|
|
60
|
+
last_update timestamp
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
✔ Generated SQL dump file (Oracle): schema.sql
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Table staff {
|
|
2
|
+
id int [pk]
|
|
3
|
+
first_name nvarchar2(255)
|
|
4
|
+
last_name nvarchar2(255)
|
|
5
|
+
address_id int
|
|
6
|
+
picture blob
|
|
7
|
+
email nvarchar2(255)
|
|
8
|
+
store_id int [ref: > store.id]
|
|
9
|
+
active number(1)
|
|
10
|
+
user_name nvarchar2(255)
|
|
11
|
+
password nvarchar2(255)
|
|
12
|
+
last_update timestamp
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Table store {
|
|
16
|
+
id int [pk]
|
|
17
|
+
manager_staff_id int [ref: > staff.id]
|
|
18
|
+
address_id int
|
|
19
|
+
last_update timestamp
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
table payment {
|
|
23
|
+
id int [pk]
|
|
24
|
+
customer_id int
|
|
25
|
+
staff_id int [ref: > staff.id]
|
|
26
|
+
rental_id int [ref: > rental.id]
|
|
27
|
+
amount float
|
|
28
|
+
payment_date date
|
|
29
|
+
last_update timestamp
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Table rental {
|
|
33
|
+
id int [pk]
|
|
34
|
+
rental_date date
|
|
35
|
+
inventory_id int
|
|
36
|
+
customer_id int
|
|
37
|
+
return_date date
|
|
38
|
+
staff_id int [ref: > staff.id]
|
|
39
|
+
last_update timestamp
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Table country {
|
|
2
|
+
id int [pk]
|
|
3
|
+
country nvarchar2(255)
|
|
4
|
+
last_update timestamp
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Table city {
|
|
8
|
+
id int [pk]
|
|
9
|
+
city nvarchar2(255)
|
|
10
|
+
country_id int [ref: > country.id]
|
|
11
|
+
last_update timestamp
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Table address {
|
|
15
|
+
id int [pk]
|
|
16
|
+
address nvarchar2(255)
|
|
17
|
+
address2 nvarchar2(255)
|
|
18
|
+
district nvarchar2(255)
|
|
19
|
+
city_id int [ref: > city.id]
|
|
20
|
+
postal_code nvarchar2(255)
|
|
21
|
+
phone nvarchar2(255)
|
|
22
|
+
last_update timestamp
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Table customer {
|
|
26
|
+
id int [pk]
|
|
27
|
+
store_id int
|
|
28
|
+
first_name nvarchar2(255)
|
|
29
|
+
last_name nvarchar2(255)
|
|
30
|
+
email nvarchar2(255)
|
|
31
|
+
address_id int [ref: > address.id]
|
|
32
|
+
active number(1)
|
|
33
|
+
create_Date timestamp
|
|
34
|
+
last_update timestamp
|
|
35
|
+
|
|
36
|
+
Indexes {
|
|
37
|
+
(id, first_name) [type: btree, name: "IDX_CUSTOMER"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Table category {
|
|
2
|
+
id int [pk]
|
|
3
|
+
name nvarchar2(255)
|
|
4
|
+
last_update timestamp
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Table film_category {
|
|
8
|
+
id int [pk]
|
|
9
|
+
category_id int [ref: > category.id]
|
|
10
|
+
last_update timestamp
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Table language {
|
|
14
|
+
id int [pk]
|
|
15
|
+
name nvarchar2(255)
|
|
16
|
+
last_update timestamp
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Table film_text {
|
|
20
|
+
id int [pk]
|
|
21
|
+
film_id int [ref: > film.id]
|
|
22
|
+
title nvarchar2(255)
|
|
23
|
+
description nclob
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Table actor {
|
|
27
|
+
id int [pk]
|
|
28
|
+
first_name nvarchar2(255)
|
|
29
|
+
last_name nvarchar2(255)
|
|
30
|
+
last_update timestamp
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Table film {
|
|
34
|
+
id int [pk]
|
|
35
|
+
title nvarchar2(255)
|
|
36
|
+
description nclob
|
|
37
|
+
releaase_year int
|
|
38
|
+
language_id int [ref: > language.id]
|
|
39
|
+
original_language_id int [ref: > language.id]
|
|
40
|
+
rental_duration int
|
|
41
|
+
rental_rate float
|
|
42
|
+
length int
|
|
43
|
+
replacement_cost float
|
|
44
|
+
rating nvarchar2(255)
|
|
45
|
+
special_feature nvarchar2(255)
|
|
46
|
+
last_update timestamp
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Table film_actor {
|
|
50
|
+
id int [pk]
|
|
51
|
+
film_id int [ref: > film.id]
|
|
52
|
+
actor_id int [ref: > actor.id]
|
|
53
|
+
last_update timestamp
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Table inventory {
|
|
57
|
+
id int [pk]
|
|
58
|
+
film_id int [ref: > film.id]
|
|
59
|
+
store_id int
|
|
60
|
+
last_update timestamp
|
|
61
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
CREATE TABLE "staff" (
|
|
2
|
+
"id" int PRIMARY KEY,
|
|
3
|
+
"first_name" nvarchar2(255),
|
|
4
|
+
"last_name" nvarchar2(255),
|
|
5
|
+
"address_id" int,
|
|
6
|
+
"picture" blob,
|
|
7
|
+
"email" nvarchar2(255),
|
|
8
|
+
"store_id" int,
|
|
9
|
+
"active" number(1),
|
|
10
|
+
"user_name" nvarchar2(255),
|
|
11
|
+
"password" nvarchar2(255),
|
|
12
|
+
"last_update" timestamp
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE "store" (
|
|
16
|
+
"id" int PRIMARY KEY,
|
|
17
|
+
"manager_staff_id" int,
|
|
18
|
+
"address_id" int,
|
|
19
|
+
"last_update" timestamp
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE "payment" (
|
|
23
|
+
"id" int PRIMARY KEY,
|
|
24
|
+
"customer_id" int,
|
|
25
|
+
"staff_id" int,
|
|
26
|
+
"rental_id" int,
|
|
27
|
+
"amount" float,
|
|
28
|
+
"payment_date" date,
|
|
29
|
+
"last_update" timestamp
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE TABLE "rental" (
|
|
33
|
+
"id" int PRIMARY KEY,
|
|
34
|
+
"rental_date" date,
|
|
35
|
+
"inventory_id" int,
|
|
36
|
+
"customer_id" int,
|
|
37
|
+
"return_date" date,
|
|
38
|
+
"staff_id" int,
|
|
39
|
+
"last_update" timestamp
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
ALTER TABLE "staff" ADD FOREIGN KEY ("store_id") REFERENCES "store" ("id");
|
|
43
|
+
|
|
44
|
+
ALTER TABLE "store" ADD FOREIGN KEY ("manager_staff_id") REFERENCES "staff" ("id");
|
|
45
|
+
|
|
46
|
+
ALTER TABLE "payment" ADD FOREIGN KEY ("staff_id") REFERENCES "staff" ("id");
|
|
47
|
+
|
|
48
|
+
ALTER TABLE "payment" ADD FOREIGN KEY ("rental_id") REFERENCES "rental" ("id");
|
|
49
|
+
|
|
50
|
+
ALTER TABLE "rental" ADD FOREIGN KEY ("staff_id") REFERENCES "staff" ("id");
|
|
51
|
+
|
|
52
|
+
CREATE TABLE "country" (
|
|
53
|
+
"id" int PRIMARY KEY,
|
|
54
|
+
"country" nvarchar2(255),
|
|
55
|
+
"last_update" timestamp
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE "city" (
|
|
59
|
+
"id" int PRIMARY KEY,
|
|
60
|
+
"city" nvarchar2(255),
|
|
61
|
+
"country_id" int,
|
|
62
|
+
"last_update" timestamp
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
CREATE TABLE "address" (
|
|
66
|
+
"id" int PRIMARY KEY,
|
|
67
|
+
"address" nvarchar2(255),
|
|
68
|
+
"address2" nvarchar2(255),
|
|
69
|
+
"district" nvarchar2(255),
|
|
70
|
+
"city_id" int,
|
|
71
|
+
"postal_code" nvarchar2(255),
|
|
72
|
+
"phone" nvarchar2(255),
|
|
73
|
+
"last_update" timestamp
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
CREATE TABLE "customer" (
|
|
77
|
+
"id" int PRIMARY KEY,
|
|
78
|
+
"store_id" int,
|
|
79
|
+
"first_name" nvarchar2(255),
|
|
80
|
+
"last_name" nvarchar2(255),
|
|
81
|
+
"email" nvarchar2(255),
|
|
82
|
+
"address_id" int,
|
|
83
|
+
"active" number(1),
|
|
84
|
+
"create_Date" timestamp,
|
|
85
|
+
"last_update" timestamp
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
CREATE INDEX "IDX_CUSTOMER" ON "customer" ("id", "first_name");
|
|
89
|
+
|
|
90
|
+
ALTER TABLE "city" ADD FOREIGN KEY ("country_id") REFERENCES "country" ("id");
|
|
91
|
+
|
|
92
|
+
ALTER TABLE "address" ADD FOREIGN KEY ("city_id") REFERENCES "city" ("id");
|
|
93
|
+
|
|
94
|
+
ALTER TABLE "customer" ADD FOREIGN KEY ("address_id") REFERENCES "address" ("id");
|
|
95
|
+
|
|
96
|
+
CREATE TABLE "category" (
|
|
97
|
+
"id" int PRIMARY KEY,
|
|
98
|
+
"name" nvarchar2(255),
|
|
99
|
+
"last_update" timestamp
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
CREATE TABLE "film_category" (
|
|
103
|
+
"id" int PRIMARY KEY,
|
|
104
|
+
"category_id" int,
|
|
105
|
+
"last_update" timestamp
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
CREATE TABLE "language" (
|
|
109
|
+
"id" int PRIMARY KEY,
|
|
110
|
+
"name" nvarchar2(255),
|
|
111
|
+
"last_update" timestamp
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
CREATE TABLE "film_text" (
|
|
115
|
+
"id" int PRIMARY KEY,
|
|
116
|
+
"film_id" int,
|
|
117
|
+
"title" nvarchar2(255),
|
|
118
|
+
"description" nclob
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
CREATE TABLE "actor" (
|
|
122
|
+
"id" int PRIMARY KEY,
|
|
123
|
+
"first_name" nvarchar2(255),
|
|
124
|
+
"last_name" nvarchar2(255),
|
|
125
|
+
"last_update" timestamp
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
CREATE TABLE "film" (
|
|
129
|
+
"id" int PRIMARY KEY,
|
|
130
|
+
"title" nvarchar2(255),
|
|
131
|
+
"description" nclob,
|
|
132
|
+
"releaase_year" int,
|
|
133
|
+
"language_id" int,
|
|
134
|
+
"original_language_id" int,
|
|
135
|
+
"rental_duration" int,
|
|
136
|
+
"rental_rate" float,
|
|
137
|
+
"length" int,
|
|
138
|
+
"replacement_cost" float,
|
|
139
|
+
"rating" nvarchar2(255),
|
|
140
|
+
"special_feature" nvarchar2(255),
|
|
141
|
+
"last_update" timestamp
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
CREATE TABLE "film_actor" (
|
|
145
|
+
"id" int PRIMARY KEY,
|
|
146
|
+
"film_id" int,
|
|
147
|
+
"actor_id" int,
|
|
148
|
+
"last_update" timestamp
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
CREATE TABLE "inventory" (
|
|
152
|
+
"id" int PRIMARY KEY,
|
|
153
|
+
"film_id" int,
|
|
154
|
+
"store_id" int,
|
|
155
|
+
"last_update" timestamp
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
ALTER TABLE "film_category" ADD FOREIGN KEY ("category_id") REFERENCES "category" ("id");
|
|
159
|
+
|
|
160
|
+
ALTER TABLE "film_text" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
161
|
+
|
|
162
|
+
ALTER TABLE "film" ADD FOREIGN KEY ("language_id") REFERENCES "language" ("id");
|
|
163
|
+
|
|
164
|
+
ALTER TABLE "film" ADD FOREIGN KEY ("original_language_id") REFERENCES "language" ("id");
|
|
165
|
+
|
|
166
|
+
ALTER TABLE "film_actor" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
167
|
+
|
|
168
|
+
ALTER TABLE "film_actor" ADD FOREIGN KEY ("actor_id") REFERENCES "actor" ("id");
|
|
169
|
+
|
|
170
|
+
ALTER TABLE "inventory" ADD FOREIGN KEY ("film_id") REFERENCES "film" ("id");
|
|
171
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
CREATE USER "C##test01"
|
|
2
|
+
NO AUTHENTICATION
|
|
3
|
+
DEFAULT TABLESPACE system
|
|
4
|
+
TEMPORARY TABLESPACE temp
|
|
5
|
+
QUOTA UNLIMITED ON system;
|
|
6
|
+
|
|
7
|
+
CREATE USER "C##test02"
|
|
8
|
+
NO AUTHENTICATION
|
|
9
|
+
DEFAULT TABLESPACE system
|
|
10
|
+
TEMPORARY TABLESPACE temp
|
|
11
|
+
QUOTA UNLIMITED ON system;
|
|
12
|
+
|
|
13
|
+
CREATE TABLE "users" (
|
|
14
|
+
"id" int PRIMARY KEY
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE "products" (
|
|
18
|
+
"id" int PRIMARY KEY,
|
|
19
|
+
"user_id" int NOT NULL
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE "C##test02"."users_products" (
|
|
23
|
+
"users_id" int,
|
|
24
|
+
"products_id" int,
|
|
25
|
+
PRIMARY KEY ("users_id", "products_id")
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE TABLE "users_products" (
|
|
29
|
+
"users_id" int,
|
|
30
|
+
"products_id" int,
|
|
31
|
+
PRIMARY KEY ("users_id", "products_id")
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
CREATE TABLE "C##test01"."users_products" (
|
|
35
|
+
"users_id" int,
|
|
36
|
+
"products_id" int,
|
|
37
|
+
PRIMARY KEY ("users_id", "products_id")
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE "C##test01"."users" (
|
|
41
|
+
"id" int PRIMARY KEY
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE TABLE "C##test01"."products" (
|
|
45
|
+
"id" int PRIMARY KEY,
|
|
46
|
+
"user_id" int NOT NULL
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
CREATE TABLE "C##test02"."users" (
|
|
50
|
+
"id" int PRIMARY KEY
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
CREATE TABLE "C##test02"."products" (
|
|
54
|
+
"id" int PRIMARY KEY,
|
|
55
|
+
"user_id" int NOT NULL
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
GRANT REFERENCES ON "C##test01"."users" TO PUBLIC;
|
|
59
|
+
|
|
60
|
+
GRANT REFERENCES ON "users" TO PUBLIC;
|
|
61
|
+
|
|
62
|
+
GRANT REFERENCES ON "C##test02"."users" TO PUBLIC;
|
|
63
|
+
|
|
64
|
+
GRANT REFERENCES ON "products" TO PUBLIC;
|
|
65
|
+
|
|
66
|
+
GRANT REFERENCES ON "C##test02"."products" TO PUBLIC;
|
|
67
|
+
|
|
68
|
+
ALTER TABLE "products" ADD FOREIGN KEY ("user_id") REFERENCES "C##test01"."users" ("id");
|
|
69
|
+
|
|
70
|
+
ALTER TABLE "C##test01"."products" ADD FOREIGN KEY ("user_id") REFERENCES "users" ("id");
|
|
71
|
+
|
|
72
|
+
ALTER TABLE "C##test01"."products" ADD FOREIGN KEY ("user_id") REFERENCES "C##test01"."users" ("id");
|
|
73
|
+
|
|
74
|
+
ALTER TABLE "C##test02"."users_products" ADD FOREIGN KEY ("users_id") REFERENCES "C##test02"."users" ("id");
|
|
75
|
+
|
|
76
|
+
ALTER TABLE "C##test02"."users_products" ADD FOREIGN KEY ("products_id") REFERENCES "products" ("id");
|
|
77
|
+
|
|
78
|
+
ALTER TABLE "users_products" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id");
|
|
79
|
+
|
|
80
|
+
ALTER TABLE "users_products" ADD FOREIGN KEY ("products_id") REFERENCES "C##test02"."products" ("id");
|
|
81
|
+
|
|
82
|
+
ALTER TABLE "C##test01"."users_products" ADD FOREIGN KEY ("users_id") REFERENCES "C##test01"."users" ("id");
|
|
83
|
+
|
|
84
|
+
ALTER TABLE "C##test01"."users_products" ADD FOREIGN KEY ("products_id") REFERENCES "C##test02"."products" ("id");
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Table users {
|
|
2
|
+
id int [pk]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
Table products {
|
|
6
|
+
id int [pk]
|
|
7
|
+
user_id int [not null]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Table "C##test01"."users" {
|
|
11
|
+
id int [pk]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Table "C##test01"."products" {
|
|
15
|
+
id int [pk]
|
|
16
|
+
user_id int [not null]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Table "C##test02"."users" {
|
|
20
|
+
id int [pk]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Table "C##test02"."products" {
|
|
24
|
+
id int [pk]
|
|
25
|
+
user_id int [not null]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// default to schema
|
|
29
|
+
Ref: "C##test01"."users"."id" < "public"."products"."user_id"
|
|
30
|
+
|
|
31
|
+
// schema to default
|
|
32
|
+
Ref: "public"."users"."id" < "C##test01"."products"."user_id"
|
|
33
|
+
|
|
34
|
+
// schema to schema
|
|
35
|
+
Ref: "C##test01"."users"."id" < "C##test01"."products"."user_id"
|
|
36
|
+
|
|
37
|
+
// many to many
|
|
38
|
+
// default - schema
|
|
39
|
+
Ref: "C##test02"."users"."id" <> "public"."products"."id"
|
|
40
|
+
|
|
41
|
+
// schema - default
|
|
42
|
+
Ref: "public"."users"."id" <> "C##test02"."products"."id"
|
|
43
|
+
|
|
44
|
+
// schema - schema
|
|
45
|
+
Ref: "C##test01"."users"."id" <> "C##test02"."products"."id"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
✔ Generated SQL dump file (Oracle): multiple_schema.out.sql
|
package/lib/cli/config.js
CHANGED
package/lib/cli/export.js
CHANGED
|
@@ -24,11 +24,12 @@ async function exportHandler(program) {
|
|
|
24
24
|
if (!opts.outFile && !opts.outDir) {
|
|
25
25
|
(0, _utils.generate)(inputPaths, dbml => _core.exporter.export(dbml, format), _outputConsolePlugin.default);
|
|
26
26
|
} else if (opts.outFile) {
|
|
27
|
-
const header = ['-- SQL dump generated using DBML (dbml
|
|
27
|
+
const header = ['-- SQL dump generated using DBML (dbml.dbdiagram.io)\n', `-- Database: ${_config.default[format].name}\n`, `-- Generated at: ${new Date().toISOString()}\n\n`].join('');
|
|
28
28
|
(0, _utils.generate)(inputPaths, dbml => _core.exporter.export(dbml, format), new _outputFilePlugin.default((0, _utils.resolvePaths)(opts.outFile), header));
|
|
29
29
|
console.log(` ${_chalk.default.green(_figures.default.main.tick)} Generated SQL dump file (${_config.default[format].name}): ${_path.default.basename(opts.outFile)}`);
|
|
30
30
|
}
|
|
31
31
|
} catch (errors) {
|
|
32
|
+
// TODO: handle error in case errors object is not mappable
|
|
32
33
|
_logger.default.error(`\n ${errors.map(({
|
|
33
34
|
message
|
|
34
35
|
}) => message).join('\n ')}`);
|
package/lib/cli/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var _package = _interopRequireDefault(require("../../package.json"));
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function dbml2sql(args) {
|
|
14
14
|
_commander.default.version(_package.default.version);
|
|
15
|
-
_commander.default.usage('[options] <files...>').option('--mysql').option('--postgres').option('--mssql').option('-o, --out-file <pathspec>', 'compile all input files into a single files');
|
|
15
|
+
_commander.default.usage('[options] <files...>').option('--mysql').option('--postgres').option('--mssql').option('--oracle').option('-o, --out-file <pathspec>', 'compile all input files into a single files');
|
|
16
16
|
// .option('-d, --out-dir <pathspec>', 'compile an input directory of dbml files into an output directory');
|
|
17
17
|
|
|
18
18
|
_commander.default.parse(args);
|
package/lib/cli/utils.js
CHANGED
|
@@ -22,7 +22,7 @@ function validateInputFilePaths(paths, validatePlugin) {
|
|
|
22
22
|
}
|
|
23
23
|
function getFormatOpt(opts) {
|
|
24
24
|
const formatOpts = Object.keys(opts).filter(opt => {
|
|
25
|
-
return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy'].includes(opt);
|
|
25
|
+
return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy', 'oracle'].includes(opt);
|
|
26
26
|
});
|
|
27
27
|
let format = 'postgres';
|
|
28
28
|
let cnt = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/cli": "^7.21.0",
|
|
28
|
-
"@dbml/core": "^3.
|
|
28
|
+
"@dbml/core": "^3.4.0",
|
|
29
29
|
"bluebird": "^3.5.5",
|
|
30
30
|
"chalk": "^2.4.2",
|
|
31
31
|
"commander": "^2.20.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"^.+\\.js$": "babel-jest"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "d46067f19bf80a245c77576106dac68bec5cbe5a"
|
|
57
57
|
}
|
package/src/cli/config.js
CHANGED
package/src/cli/export.js
CHANGED
|
@@ -26,17 +26,21 @@ export default async function exportHandler (program) {
|
|
|
26
26
|
generate(inputPaths, (dbml) => exporter.export(dbml, format), OutputConsolePlugin);
|
|
27
27
|
} else if (opts.outFile) {
|
|
28
28
|
const header = [
|
|
29
|
-
'-- SQL dump generated using DBML (dbml
|
|
29
|
+
'-- SQL dump generated using DBML (dbml.dbdiagram.io)\n',
|
|
30
30
|
`-- Database: ${config[format].name}\n`,
|
|
31
31
|
`-- Generated at: ${new Date().toISOString()}\n\n`,
|
|
32
32
|
].join('');
|
|
33
33
|
|
|
34
|
-
generate(
|
|
35
|
-
|
|
34
|
+
generate(
|
|
35
|
+
inputPaths,
|
|
36
|
+
(dbml) => exporter.export(dbml, format),
|
|
37
|
+
new OutputFilePlugin(resolvePaths(opts.outFile), header)
|
|
38
|
+
);
|
|
36
39
|
|
|
37
40
|
console.log(` ${chalk.green(figures.main.tick)} Generated SQL dump file (${config[format].name}): ${path.basename(opts.outFile)}`);
|
|
38
41
|
}
|
|
39
42
|
} catch (errors) {
|
|
43
|
+
// TODO: handle error in case errors object is not mappable
|
|
40
44
|
logger.error(`\n ${errors.map(({ message }) => message).join('\n ')}`);
|
|
41
45
|
}
|
|
42
46
|
}
|
package/src/cli/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function dbml2sql (args) {
|
|
|
11
11
|
.option('--mysql')
|
|
12
12
|
.option('--postgres')
|
|
13
13
|
.option('--mssql')
|
|
14
|
+
.option('--oracle')
|
|
14
15
|
.option('-o, --out-file <pathspec>', 'compile all input files into a single files');
|
|
15
16
|
// .option('-d, --out-dir <pathspec>', 'compile an input directory of dbml files into an output directory');
|
|
16
17
|
|
package/src/cli/utils.js
CHANGED
|
@@ -15,7 +15,7 @@ function validateInputFilePaths (paths, validatePlugin) {
|
|
|
15
15
|
|
|
16
16
|
function getFormatOpt (opts) {
|
|
17
17
|
const formatOpts = Object.keys(opts).filter((opt) => {
|
|
18
|
-
return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy'].includes(opt);
|
|
18
|
+
return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy', 'oracle'].includes(opt);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
let format = 'postgres';
|