From ba43e432b0ac771247b1ff143fb7f7907c245c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Nagli=C4=8D?= Date: Fri, 12 Jan 2024 18:15:50 +0100 Subject: [PATCH] Add initial database schema The commit introduces the initial database schema. It includes creation of tables such as `tenant`, `service`, `tenant_service`, `permission`, `role`, `role_permission`, `user`, and `user_role`. The schema lays down the foundation for the database structure of our project. --- .../db/migration/V1__initial_schema.sql | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/resources/db/migration/V1__initial_schema.sql diff --git a/src/main/resources/db/migration/V1__initial_schema.sql b/src/main/resources/db/migration/V1__initial_schema.sql new file mode 100644 index 0000000..72fda35 --- /dev/null +++ b/src/main/resources/db/migration/V1__initial_schema.sql @@ -0,0 +1,62 @@ +CREATE TABLE tenant +( + id int AUTO_INCREMENT PRIMARY KEY, + name varchar(255) NOT NULL, + status varchar(255) NOT NULL +); + +CREATE TABLE service +( + id int AUTO_INCREMENT PRIMARY KEY, + name varchar(255) NOT NULL, + description text, + status varchar(255) +); + +CREATE TABLE tenant_service +( + tenant_id int NOT NULL, + service_id int NOT NULL, + status varchar(255), + PRIMARY KEY (tenant_id, service_id) +); + +CREATE TABLE permission +( + id int AUTO_INCREMENT PRIMARY KEY, + name varchar(255) NOT NULL, + description text, + scope varchar(255) +); + +CREATE TABLE role +( + id int AUTO_INCREMENT PRIMARY KEY, + name varchar(255) NOT NULL, + description text +); + +CREATE TABLE role_permission +( + role_id int NOT NULL, + permission_id int NOT NULL, + PRIMARY KEY (role_id, permission_id) +); + +CREATE TABLE user +( + id int AUTO_INCREMENT PRIMARY KEY, + email varchar(255) NOT NULL, + password varchar(255), + status varchar(255), + UNIQUE KEY unique_email (email) +); + +CREATE TABLE user_role +( + tenant_id int NOT NULL, + user_id int NOT NULL, + role_id int NOT NULL, + PRIMARY KEY (tenant_id, user_id, role_id) +); +