-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] MySQL DB repository support (#78)
* TASK: [gw] Extract ORM repository to be used by repos as a delegate * FEAT: [gw] Add MySQL support (using diesel ORM) * TASK: [doc] Update gw invocation doc for new mysql config * TASK: [example] Add support for using MySQL datasource
- Loading branch information
Showing
42 changed files
with
5,053 additions
and
3,273 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// @generated automatically by Diesel CLI. | ||
|
||
diesel::table! { | ||
roles (id) { | ||
id -> Bigint, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
service_accesses (entity_type, entity_id, service_id) { | ||
#[max_length = 20] | ||
entity_type -> Varchar, | ||
entity_id -> Bigint, | ||
service_id -> Bigint, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
services (id) { | ||
id -> Bigint, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
#[max_length = 20] | ||
transport -> Varchar, | ||
#[max_length = 255] | ||
host -> Varchar, | ||
port -> Integer, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
user_roles (user_id, role_id) { | ||
user_id -> Bigint, | ||
role_id -> Bigint, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
users (id) { | ||
id -> Bigint, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
#[max_length = 20] | ||
status -> Varchar, | ||
#[max_length = 50] | ||
user_name -> Nullable<Varchar>, | ||
#[max_length = 255] | ||
password -> Nullable<Varchar>, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::joinable!(service_accesses -> services (service_id)); | ||
diesel::joinable!(user_roles -> roles (role_id)); | ||
diesel::joinable!(user_roles -> users (user_id)); | ||
|
||
diesel::allow_tables_to_appear_in_same_query!( | ||
roles, | ||
service_accesses, | ||
services, | ||
user_roles, | ||
users, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// @generated automatically by Diesel CLI. | ||
|
||
diesel::table! { | ||
roles (id) { | ||
id -> Int8, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
service_accesses (entity_type, entity_id, service_id) { | ||
#[max_length = 20] | ||
entity_type -> Varchar, | ||
entity_id -> Int8, | ||
service_id -> Int8, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
services (id) { | ||
id -> Int8, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
#[max_length = 20] | ||
transport -> Varchar, | ||
#[max_length = 255] | ||
host -> Varchar, | ||
port -> Int4, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
user_roles (user_id, role_id) { | ||
user_id -> Int8, | ||
role_id -> Int8, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::table! { | ||
users (id) { | ||
id -> Int8, | ||
#[max_length = 50] | ||
name -> Varchar, | ||
#[max_length = 20] | ||
status -> Varchar, | ||
#[max_length = 50] | ||
user_name -> Nullable<Varchar>, | ||
#[max_length = 255] | ||
password -> Nullable<Varchar>, | ||
created_at -> Nullable<Timestamp>, | ||
updated_at -> Nullable<Timestamp>, | ||
} | ||
} | ||
|
||
diesel::joinable!(service_accesses -> services (service_id)); | ||
diesel::joinable!(user_roles -> roles (role_id)); | ||
diesel::joinable!(user_roles -> users (user_id)); | ||
|
||
diesel::allow_tables_to_appear_in_same_query!( | ||
roles, | ||
service_accesses, | ||
services, | ||
user_roles, | ||
users, | ||
); |
1 change: 1 addition & 0 deletions
1
crates/gateway/migrations/mysql/2024-02-28-000000_create_roles_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE roles; |
6 changes: 6 additions & 0 deletions
6
crates/gateway/migrations/mysql/2024-02-28-000000_create_roles_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE roles ( | ||
id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(50) NOT NULL, | ||
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
); |
1 change: 1 addition & 0 deletions
1
crates/gateway/migrations/mysql/2024-02-28-000001_create_users_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE users; |
9 changes: 9 additions & 0 deletions
9
crates/gateway/migrations/mysql/2024-02-28-000001_create_users_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE users ( | ||
id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(50) NOT NULL, | ||
status VARCHAR(20) NOT NULL CHECK (status IN ('Active', 'Inactive')), | ||
user_name VARCHAR(50) NULL, | ||
password VARCHAR(255) NULL, | ||
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
); |
1 change: 1 addition & 0 deletions
1
crates/gateway/migrations/mysql/2024-02-28-000002_create_user_roles_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE user_roles; |
7 changes: 7 additions & 0 deletions
7
crates/gateway/migrations/mysql/2024-02-28-000002_create_user_roles_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE user_roles ( | ||
user_id BIGINT NOT NULL REFERENCES users(id), | ||
role_id BIGINT NOT NULL REFERENCES roles(id), | ||
PRIMARY KEY (user_id, role_id), | ||
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
); |
1 change: 1 addition & 0 deletions
1
crates/gateway/migrations/mysql/2024-02-28-000003_create_services_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE services; |
9 changes: 9 additions & 0 deletions
9
crates/gateway/migrations/mysql/2024-02-28-000003_create_services_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE services ( | ||
id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(50) NOT NULL, | ||
transport VARCHAR(20) NOT NULL CHECK (transport IN ('TCP', 'UDP')), | ||
host VARCHAR(255) NOT NULL, | ||
port INTEGER NOT NULL, | ||
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
); |
1 change: 1 addition & 0 deletions
1
crates/gateway/migrations/mysql/2024-02-28-000004_create_service_accesses_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE service_accesses; |
11 changes: 11 additions & 0 deletions
11
crates/gateway/migrations/mysql/2024-02-28-000004_create_service_accesses_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE service_accesses ( | ||
entity_type VARCHAR(20) NOT NULL CHECK (entity_type IN ('Role', 'User')), | ||
entity_id BIGINT NOT NULL, | ||
service_id BIGINT NOT NULL, | ||
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (entity_type, entity_id, service_id), | ||
FOREIGN KEY(service_id) | ||
REFERENCES services(id) | ||
ON DELETE CASCADE | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.