Skip to content

Conversation

@ndthang15
Copy link
Owner

No description provided.

Comment on lines +1 to +3
DROP TYPE IF EXISTS organization_status_type;
DROP TYPE IF EXISTS user_status_type;
DROP TYPE IF EXISTS sex_type;
Copy link
Owner Author

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.

Comment on lines +9 to +14
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;
Copy link
Owner Author

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,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Owner Author

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()

Suggested change
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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PRIMARY KEY(profile_id)
PRIMARY KEY(profile_id),

FOREIGN KEY (user_id) REFERENCES sso_user(user_id)
);

CREATE TABLE IF NOT EXISTS sso_roles (
Copy link
Owner Author

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é

Suggested change
CREATE TABLE IF NOT EXISTS sso_roles (
CREATE TABLE IF NOT EXISTS sso_role (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants