Skip to content

update grouper to midpoint DDL #163

Merged
merged 1 commit into from Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions Workbench/grouper_data/container_files/sql/createDBforMP.sql
@@ -1,6 +1,6 @@
CREATE DATABASE grouper_to_midpoint;
GRANT ALL PRIVILEGES ON DATABASE grouper_to_midpoint TO grouper;

\connect grouper_to_midpoint;
set role grouper;

Expand Down Expand Up @@ -49,8 +49,8 @@ CREATE TABLE gr_mp_group_attributes (
attribute_value varchar(4000) NULL, -- Attribute value could be null
last_modified int8 NOT NULL, -- Millis since 1970, will be sequential and unique
deleted varchar(1) NOT NULL, -- T or F. Deleted rows will be removed after they have had time to be processed
CONSTRAINT gr_mp_group_attributes_fk FOREIGN KEY (group_id_index) REFERENCES gr_mp_groups(id_index)
);
CONSTRAINT gr_mp_group_attributes_fk FOREIGN KEY (group_id_index) REFERENCES gr_mp_groups(id_index) ON DELETE CASCADE
);
CREATE UNIQUE INDEX gr_mp_group_attributes_idx ON gr_mp_group_attributes(group_id_index, attribute_name, attribute_value);
CREATE UNIQUE INDEX gr_mp_group_attributes_ldx ON gr_mp_group_attributes(last_modified);
COMMENT ON TABLE gr_mp_group_attributes IS 'This table holds group attributes which are one to one or one to many to the groups table';
Expand All @@ -66,9 +66,9 @@ CREATE TABLE gr_mp_memberships (
subject_id_index int8 NOT NULL, -- This is the foreign key to subjects
last_modified int8 NOT NULL, -- Millis since 1970, will be sequential and unique
deleted varchar(1) NOT NULL, -- T or F. Deleted rows will be removed after they have had time to be processed
CONSTRAINT gr_mp_memberships_gfk FOREIGN KEY (group_id_index) REFERENCES gr_mp_groups(id_index),
CONSTRAINT gr_mp_memberships_sfk FOREIGN KEY (subject_id_index) REFERENCES gr_mp_subjects(subject_id_index)
);
CONSTRAINT gr_mp_memberships_gfk FOREIGN KEY (group_id_index) REFERENCES gr_mp_groups(id_index) ON DELETE CASCADE,
CONSTRAINT gr_mp_memberships_sfk FOREIGN KEY (subject_id_index) REFERENCES gr_mp_subjects(subject_id_index) ON DELETE CASCADE
);
CREATE UNIQUE INDEX gr_mp_memberships_idx ON gr_mp_memberships(group_id_index, subject_id_index);
CREATE UNIQUE INDEX gr_mp_memberships_ldx ON gr_mp_memberships(last_modified);
COMMENT ON TABLE gr_mp_memberships IS 'This table holds memberships. The primary key is group_id_index and subject_id_index';
Expand All @@ -84,8 +84,8 @@ CREATE TABLE gr_mp_subject_attributes (
attribute_value varchar(4000) NULL, -- Attribute value could be null
last_modified int8 NOT NULL, -- Millis since 1970, will be sequential and unique
deleted varchar(1) NOT NULL, -- T or F. Deleted rows will be removed after they have had time to be processed
CONSTRAINT gr_mp_subject_attributes_fk FOREIGN KEY (subject_id_index) REFERENCES gr_mp_subjects(subject_id_index)
);
CONSTRAINT gr_mp_subject_attributes_fk FOREIGN KEY (subject_id_index) REFERENCES gr_mp_subjects(subject_id_index) ON DELETE CASCADE
);
CREATE UNIQUE INDEX gr_mp_subject_attributes_idx ON gr_mp_subject_attributes(subject_id_index, attribute_name, attribute_value);
CREATE UNIQUE INDEX gr_mp_subject_attributes_ldx ON gr_mp_subject_attributes(last_modified);
COMMENT ON TABLE gr_mp_subject_attributes IS 'This table holds subject attributes which are one to one or one to many to the subjects table';
Expand Down