Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Oct 16, 2021
1 parent 7a229b9 commit 2011242
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 0 deletions.
90 changes: 90 additions & 0 deletions ADR/chart.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//// -- https://dbdiagram.io/

Table option {
id int [pk, increment] // auto-increment
key varchar
value mediumtext
created_at datetime [default: `now()`]
updated_at datetime
}

Table endpoint {
id int [pk, increment] // auto-increment
status varchar
listen_path varchar
name varchar
upstreams mediumtext
balancing varchar
http_methods varchar
authentication varchar
rate_limit varchar
circuit_breaker varchar
created_at datetime [default: `now()`]
updated_at datetime
}

Table auth_method {
id int [pk, increment] // auto-increment
name varchar
description varchar
type varchar
created_at datetime [default: `now()`]
updated_at datetime
}

Table endpoint_auth_method {
id int [pk, increment]
auth_method_id integer
endpoint_id integer
created_at datetime [default: `now()`]
updated_at datetime
}

Table key_based_auth_data {
id int [pk, increment]
name varchar
api_key varchar
meta varchar
auth_method_id integer
created_at datetime [default: `now()`]
updated_at datetime
}

Table basic_auth_data {
id int [pk, increment]
name varchar
username varchar
password varchar
meta varchar
auth_method_id integer
created_at datetime [default: `now()`]
updated_at datetime
}

Table oauth_data {
id int [pk, increment]
name varchar
client_id varchar
client_secret varchar
meta varchar
auth_method_id integer
created_at datetime [default: `now()`]
updated_at datetime
}

Table oauth_access_data {
id int [pk, increment]
access_token varchar
meta varchar
expire_at datetime
oauth_data_id integer
created_at datetime [default: `now()`]
updated_at datetime
}

Ref: auth_method.id > endpoint_auth_method.auth_method_id [delete: cascade, update: cascade]
Ref: endpoint.id > endpoint_auth_method.endpoint_id [delete: cascade, update: cascade]
Ref: auth_method.id > key_based_auth_data.auth_method_id [delete: cascade, update: cascade]
Ref: auth_method.id > basic_auth_data.auth_method_id [delete: cascade, update: cascade]
Ref: auth_method.id > oauth_data.auth_method_id [delete: cascade, update: cascade]
Ref: oauth_data.id > oauth_access_data.oauth_data_id [delete: cascade, update: cascade]
88 changes: 88 additions & 0 deletions ADR/db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
CREATE TABLE IF NOT EXISTS `option` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`key` varchar(60),
`value` mediumtext,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `endpoint` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`status` varchar(25),
`listen_path` varchar(200),
`name` varchar(60),
`upstreams` mediumtext,
`balancing` varchar(60),
`http_methods` varchar(60),
`authentication` varchar(60),
`rate_limit` varchar(60),
`circuit_breaker` varchar(60),
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `auth_method` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` varchar(60),
`description` varchar(200),
`type` varchar(30),
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `endpoint_auth_method` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`auth_method_id` integer,
`endpoint_id` integer,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `key_based_auth_data` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` varchar(60),
`api_key` varchar(200),
`meta` varchar(200),
`auth_method_id` integer,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `basic_auth_data` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` varchar(60),
`username` varchar(200),
`password` varchar(200),
`meta` varchar(200),
`auth_method_id` integer,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `oauth_data` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`name` varchar(60),
`client_id` varchar(200),
`client_secret` varchar(200),
`meta` varchar(200),
`auth_method_id` integer,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

CREATE TABLE IF NOT EXISTS `oauth_access_data` (
`id` int PRIMARY KEY AUTO_INCREMENT,
`access_token` varchar(200),
`meta` varchar(200),
`expire_at` datetime,
`oauth_data_id` integer,
`created_at` datetime DEFAULT (now()),
`updated_at` datetime
);

ALTER TABLE `auth_method` ADD FOREIGN KEY (`id`) REFERENCES `endpoint_auth_method` (`auth_method_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `endpoint` ADD FOREIGN KEY (`id`) REFERENCES `endpoint_auth_method` (`endpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `auth_method` ADD FOREIGN KEY (`id`) REFERENCES `key_based_auth_data` (`auth_method_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `auth_method` ADD FOREIGN KEY (`id`) REFERENCES `basic_auth_data` (`auth_method_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `auth_method` ADD FOREIGN KEY (`id`) REFERENCES `oauth_data` (`auth_method_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `oauth_data` ADD FOREIGN KEY (`id`) REFERENCES `oauth_access_data` (`oauth_data_id`) ON DELETE CASCADE ON UPDATE CASCADE;

0 comments on commit 2011242

Please sign in to comment.