Skip to content

Commit

Permalink
Merge pull request #2 from UnityFoundation-io/feature/initial-create-…
Browse files Browse the repository at this point in the history
…tables-sql

Add initial database schema
  • Loading branch information
jrw972 authored Jan 12, 2024
2 parents 9e4d21f + ba43e43 commit 8327ff1
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/main/resources/db/migration/V1__initial_schema.sql
Original file line number Diff line number Diff line change
@@ -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)
);

0 comments on commit 8327ff1

Please sign in to comment.