-
Notifications
You must be signed in to change notification settings - Fork 2
lesson 2 - tran dang thinh - homework #4
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
base: main
Are you sure you want to change the base?
Conversation
| DROP TYPE IF EXISTS organization_status_type; | ||
| DROP TYPE IF EXISTS user_status_type; | ||
| DROP TYPE IF EXISTS sex_type; |
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.
Mình ko cần DROP TYPE vì script chỉ chạy 1 lần, và xóa nếu nó đang được gắn vào bảng có thể gây lỗi.
| DROP TABLE IF EXISTS sso_organization; | ||
| DROP TABLE IF EXISTS sso_user; | ||
| DROP TABLE IF EXISTS sso_roles; | ||
| DROP TABLE IF EXISTS sso_user_profile; | ||
| DROP TABLE IF EXISTS sso_organization_user; | ||
| DROP TABLE IF EXISTS sso_user_role; |
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.
Mình không nên xóa bảng, vì nếu lỡ script chạy lần 2 vì 1 lý do nào đó, có thể sẽ bị mất dữ liệu thực tế.
Chỉ cần bên dưới tạo bảng với lệnh CREATE TABLE IF NOT EXISTS là được rồi nhé.
| organization_id SERIAL PRIMARY KEY NOT NULL, | ||
| organization_name VARCHAR(255) NOT NULL, | ||
| status organization_status_type DEFAULT 'active'::organization_status_type NOT NULL, | ||
| organization_id INT NOT NULL, |
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.
| organization_id INT NOT NULL, | |
| organization_id INT NOT NULL GENERATED ALWAYS AS IDENTITY, |
| date_modified TIMESTAMPTZ DEFAULT now() | ||
| postal_code VARCHAR(10), | ||
| organization_sub_name VARCHAR(10), | ||
| website_url VARCHAR(255) |
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.
| website_url VARCHAR(255) | |
| website_url VARCHAR(255), |
| @@ -1,69 +1,86 @@ | |||
| CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | |||
| DROP TYPE IF EXISTS organization_status_type; | |||
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.
Thêm cái này mới dùng được hàm uuid_generate_v4()
| DROP TYPE IF EXISTS organization_status_type; | |
| CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | |
| DROP TYPE IF EXISTS organization_status_type; |
|
|
||
| CREATE TABLE IF NOT EXISTS sso_roles ( | ||
| role_id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, | ||
| role_name VARCHAR(255) NOT NULL |
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.
| role_name VARCHAR(255) NOT NULL | |
| role_name VARCHAR(255) NOT NULL, |
| role_description VARCHAR(255), | ||
| organization_id INT NOT NULL, | ||
| status organization_status_type, | ||
| PRIMARY KEY (role_id) |
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.
| PRIMARY KEY (role_id) | |
| PRIMARY KEY (role_id), |
|
|
||
| CREATE TABLE IF NOT EXISTS sso_user_profile ( | ||
| profile_id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, | ||
| profile_id UUID DEFAULT uuid_generate_v4(), |
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.
| profile_id UUID DEFAULT uuid_generate_v4(), | |
| profile_id UUID DEFAULT uuid_generate_v4() NOT NULL, |
| FOREIGN KEY (organization_id) REFERENCES sso_organization(organization_id), | ||
| date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
| date_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
| PRIMARY KEY(profile_id) |
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.
| PRIMARY KEY(profile_id) | |
| PRIMARY KEY(profile_id), |
| FOREIGN KEY (user_id) REFERENCES sso_user(user_id) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS sso_roles ( |
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.
Tên bảng để số ít thôi nhé
| CREATE TABLE IF NOT EXISTS sso_roles ( | |
| CREATE TABLE IF NOT EXISTS sso_role ( |
No description provided.