Skip to content

Commit

Permalink
add file departments n:n association table - db
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Oct 22, 2024
1 parent 13b0eb2 commit abb48b2
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
30 changes: 30 additions & 0 deletions core/db/schema-create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,16 @@
VISITS_FK BIGINT not null
);

create table file_department (
FILES_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table hyperlink_department (
HYPERLINKS_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table input_field_value_selection (
INPUT_FIELD_VALUES_FK BIGINT not null,
SELECTION_VALUES_FK BIGINT not null
Expand Down Expand Up @@ -3710,6 +3720,26 @@
foreign key (ECRFS_FK)
references ecrf;

alter table file_department
add constraint DEPARTMENT_FILES_FKC
foreign key (FILES_FK)
references FILE;

alter table file_department
add constraint FILE_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table hyperlink_department
add constraint DEPARTMENT_HYPERLINKS_FKC
foreign key (HYPERLINKS_FK)
references HYPERLINK;

alter table hyperlink_department
add constraint HYPERLINK_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table input_field_value_selection
add constraint INPUT_FIELD_VALUE_SELECTION_VALUES_FKC
foreign key (SELECTION_VALUES_FK)
Expand Down
16 changes: 16 additions & 0 deletions core/db/schema-drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,18 @@
alter table ecrf_visit
drop constraint VISIT_ECRFS_FKC;

alter table file_department
drop constraint DEPARTMENT_FILES_FKC;

alter table file_department
drop constraint FILE_DEPARTMENTS_FKC;

alter table hyperlink_department
drop constraint DEPARTMENT_HYPERLINKS_FKC;

alter table hyperlink_department
drop constraint HYPERLINK_DEPARTMENTS_FKC;

alter table input_field_value_selection
drop constraint INPUT_FIELD_VALUE_SELECTION_VALUES_FKC;

Expand Down Expand Up @@ -1269,6 +1281,10 @@

drop table ecrf_visit cascade;

drop table file_department cascade;

drop table hyperlink_department cascade;

drop table input_field_value_selection cascade;

drop table mass_mail_status_transition cascade;
Expand Down
2 changes: 1 addition & 1 deletion core/db/schema-set-version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ begin
end
$$ language plpgsql;

select set_database_version('010801060');
select set_database_version('010801070');
33 changes: 33 additions & 0 deletions core/db/schema-up-master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ if get_database_version() < '010801060' then

end if;

if get_database_version() < '010801070' then

create table file_department (
FILES_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table hyperlink_department (
HYPERLINKS_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

alter table file_department
add constraint DEPARTMENT_FILES_FKC
foreign key (FILES_FK)
references FILE;

alter table file_department
add constraint FILE_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table hyperlink_department
add constraint DEPARTMENT_HYPERLINKS_FKC
foreign key (HYPERLINKS_FK)
references HYPERLINK;

alter table hyperlink_department
add constraint HYPERLINK_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

end if;

end
$$;

0 comments on commit abb48b2

Please sign in to comment.