-
Notifications
You must be signed in to change notification settings - Fork 2
Lesson 2 - Do Van Chung #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndthang15
wants to merge
1
commit into
lesson2/main
Choose a base branch
from
lesson2/do_van_chung
base: lesson2/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
flyway/postgre/migrations/sql/V1_3__Create_lesson2_tables.sql
This file contains hidden or 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,68 @@ | ||||||
| CREATE TYPE type_status AS ENUM ('active', 'deactivated', 'deleted'); | ||||||
| CREATE TYPE type_sex AS ENUM ('male', 'female'); | ||||||
| CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||||||
| CREATE TABLE IF NOT EXISTS sso_user ( | ||||||
| user_id SERIAL PRIMARY KEY, | ||||||
| user_name TEXT NOT NULL, | ||||||
| password TEXT NOT NULL, | ||||||
| email TEXT, | ||||||
| kvp JSON, | ||||||
| date_created TIMESTAMP, | ||||||
| date_modified TIMESTAMP, | ||||||
| modified_by UUID DEFAULT uuid_generate_v4(), | ||||||
| last_logged_in TIMESTAMP, | ||||||
| user_settings JSON DEFAULT '{}'::JSON, | ||||||
| status type_status DEFAULT 'active' | ||||||
| ); | ||||||
| CREATE TABLE IF NOT EXISTS sso_organization ( | ||||||
| organization_id SERIAL PRIMARY KEY, | ||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| organization_name TEXT NOT NULL, | ||||||
| kvp JSON, | ||||||
| date_created TIMESTAMP, | ||||||
| date_modified TIMESTAMP, | ||||||
| status type_status DEFAULT 'active' NOT NULL, | ||||||
| address TEXT, | ||||||
| contact_number TEXT, | ||||||
| email TEXT, | ||||||
| country TEXT, | ||||||
| state TEXT, | ||||||
| city TEXT, | ||||||
| postal_code TEXT, | ||||||
| organization_sub_name TEXT, | ||||||
| website_url TEXT | ||||||
| ); | ||||||
| CREATE TABLE IF NOT EXISTS sso_role ( | ||||||
| role_id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, | ||||||
| role_name TEXT NOT NULL, | ||||||
| role_description TEXT, | ||||||
| organization_id INT, | ||||||
| CONSTRAINT fk_organization FOREIGN KEY (organization_id) REFERENCES sso_organization (organization_id) | ||||||
| ); | ||||||
| CREATE TABLE IF NOT EXISTS sso_user_organization ( | ||||||
| organization_id INT NOT NULL, | ||||||
| user_id INT NOT NULL, | ||||||
| CONSTRAINT user_org PRIMARY KEY (organization_id, user_id), | ||||||
| CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES sso_user (user_id), | ||||||
| CONSTRAINT fk_org FOREIGN KEY (organization_id) REFERENCES sso_organization (organization_id) | ||||||
| ); | ||||||
| CREATE TABLE IF NOT EXISTS sso_user_role ( | ||||||
| user_id INT NOT NULL, | ||||||
| role_id UUID NOT NULL, | ||||||
| CONSTRAINT user_role PRIMARY KEY (user_id, role_id), | ||||||
| CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES sso_user (user_id), | ||||||
| CONSTRAINT fk_role FOREIGN KEY (role_id) REFERENCES sso_role (role_id) | ||||||
| ); | ||||||
| CREATE TABLE IF NOT EXISTS sso_user_profile ( | ||||||
| profile_id UUID DEFAULT uuid_generate_v4() NOT NULL, | ||||||
| user_id INT NOT NULL, | ||||||
| birth_date DATE, | ||||||
| sex type_sex, | ||||||
| title TEXT, | ||||||
| firstname TEXT NOT NULL, | ||||||
| lastname TEXT NOT NULL, | ||||||
| avatar TEXT, | ||||||
| age INT, | ||||||
| address TEXT, | ||||||
| date_created TIMESTAMP, | ||||||
| CONSTRAINT fk_user_profiles FOREIGN KEY (user_id) REFERENCES sso_user (user_id) | ||||||
| ); | ||||||
135 changes: 135 additions & 0 deletions
135
flyway/postgre/migrations/sql/V1_4__Insert_lesson2_initial_data.sql
This file contains hidden or 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,135 @@ | ||
| INSERT INTO sso_organization ( | ||
| organization_name, | ||
| kvp, | ||
| date_created, | ||
| date_modified, | ||
| address, | ||
| contact_number, | ||
| email, | ||
| country, | ||
| state, | ||
| city, | ||
| postal_code, | ||
| organization_sub_name, | ||
| website_url | ||
| ) | ||
| VALUES ( | ||
| 'XYZ Corporation', | ||
| '{"industry": "Technology", "employees": 750}', | ||
| NOW(), | ||
| NOW(), | ||
| '456 Elm St', | ||
| '555-1234', | ||
| '[email protected]', | ||
| 'USA', | ||
| 'California', | ||
| 'Los Angeles', | ||
| '90001', | ||
| 'XYZ West', | ||
| 'https://www.xyzcorp.com' | ||
| ), | ||
| ( | ||
| 'ABC Ltd.', | ||
| '{"industry": "Finance", "employees": 200}', | ||
| NOW(), | ||
| NOW(), | ||
| '789 Oak Ave', | ||
| '555-5678', | ||
| '[email protected]', | ||
| 'USA', | ||
| 'New York', | ||
| 'New York City', | ||
| '10001', | ||
| 'ABC East', | ||
| 'https://www.abcltd.com' | ||
| ); | ||
| INSERT INTO sso_role (role_name, role_description, organization_id) | ||
| VALUES ( | ||
| 'Administrator', | ||
| 'Full access to all features', | ||
| 2 | ||
| ), | ||
| ('Manager', 'Access to manage users and roles', 2), | ||
| ( | ||
| 'Employee', | ||
| 'Basic access to view and edit own profile', | ||
| 2 | ||
| ); | ||
| INSERT INTO sso_user ( | ||
| user_name, | ||
| password, | ||
| email, | ||
| kvp, | ||
| date_created, | ||
| date_modified, | ||
| modified_by, | ||
| last_logged_in, | ||
| user_settings, | ||
| status | ||
| ) | ||
| VALUES ( | ||
| 'user123', | ||
| 'pass456', | ||
| '[email protected]', | ||
| '{"role": "admin"}', | ||
| NOW(), | ||
| NOW(), | ||
| NULL, | ||
| NOW(), | ||
| '{"theme": "dark"}', | ||
| 'active' | ||
| ), | ||
| ( | ||
| 'user456', | ||
| 'pass789', | ||
| '[email protected]', | ||
| '{"role": "user"}', | ||
| NOW(), | ||
| NOW(), | ||
| NULL, | ||
| NOW(), | ||
| '{"theme": "light"}', | ||
| 'active' | ||
| ); | ||
| INSERT INTO sso_user_organization (organization_id, user_id) | ||
| VALUES (2, 1), | ||
| (3, 2); | ||
| INSERT INTO sso_user_role (user_id, role_id) | ||
| VALUES (1, 'c5089b76-92e5-42f0-81a3-1317322ad372'), | ||
| (1, 'ce40b375-f4de-4df8-9848-721573b39ff2'); | ||
| INSERT INTO sso_user_profile ( | ||
| user_id, | ||
| birth_date, | ||
| sex, | ||
| title, | ||
| firstname, | ||
| lastname, | ||
| avatar, | ||
| age, | ||
| address, | ||
| date_created | ||
| ) | ||
| VALUES ( | ||
| 1, | ||
| '1988-07-15', | ||
| 'male', | ||
| 'Mr.', | ||
| 'John', | ||
| 'Doe', | ||
| 'https://example.com/johndoe.jpg', | ||
| 35, | ||
| '456 Elm St, Los Angeles, California, USA', | ||
| NOW() | ||
| ), | ||
| ( | ||
| 2, | ||
| '1992-03-20', | ||
| 'female', | ||
| 'Ms.', | ||
| 'Jane', | ||
| 'Smith', | ||
| 'https://example.com/janesmith.jpg', | ||
| 29, | ||
| '789 Oak Ave, New York City, New York, USA', | ||
| NOW() | ||
| ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cần thêm generate tự tăng