Change the Timeslot table Private Key
In this Merge Request, the private key of the Timeslot is changed from an id to the date and the slot_id. This also leads to the id of the timeslot being removed.
In order to update the current master database, the following code can be executed:
ALTER TABLE Availability
ADD COLUMN date date NOT NULL,
ADD COLUMN slot_id int NOT NULL,
DROP FOREIGN KEY Availability_Timeslot,
DROP PRIMARY KEY,
ADD PRIMARY KEY (netid,date,slot_id),
DROP COLUMN timeslot_id;
ALTER TABLE LabAssignment
ADD COLUMN date date NOT NULL,
ADD COLUMN slot_id int NOT NULL,
DROP FOREIGN KEY LabAssignment_Timeslot,
DROP PRIMARY KEY,
ADD PRIMARY KEY (netid,schedule_id,date,slot_id),
DROP COLUMN timeslot_id;
ALTER TABLE LabTimeslot
ADD COLUMN date date NOT NULL,
ADD COLUMN slot_id int NOT NULL,
DROP FOREIGN KEY LabTimeslot_Timeslot,
DROP PRIMARY KEY,
ADD PRIMARY KEY (lab_id,date,slot_id),
DROP COLUMN timeslot_id;
ALTER TABLE Timeslot
DROP PRIMARY KEY,
ADD PRIMARY KEY (date, slot_id),
DROP COLUMN id;
ALTER TABLE Availability ADD CONSTRAINT Availability_Timeslot FOREIGN KEY Availability_Timeslot (date,slot_id) REFERENCES Timeslot (date,slot_id);
ALTER TABLE LabAssignment ADD CONSTRAINT LabAssignment_Timeslot FOREIGN KEY LabAssignment_Timeslot (date,slot_id) REFERENCES Timeslot (date,slot_id);
ALTER TABLE LabTimeslot ADD CONSTRAINT LabTimeslot_Timeslot FOREIGN KEY LabTimeslot_Timeslot (date,slot_id) REFERENCES Timeslot (date,slot_id);
Edited by Otto Visser
Merge request reports
Activity
added 2 commits
By Max van Deursen on 2018-05-30T15:35:26 (imported from GitLab project)
Fair point, would work too! We have to remember to run the script though when deploying
By Max van Deursen on 2018-05-30T15:36:04 (imported from GitLab project)
Edited by Otto Visseradded 3 commits
-
5ebe0da4...bec15e92 - 2 commits from branch
master
- e4ba6d27 - Change the Timeslot table Private Key
By Max van Deursen on 2018-05-31T07:17:48 (imported from GitLab project)
-
5ebe0da4...bec15e92 - 2 commits from branch
mentioned in commit 59c7a8ca
By Max Pigmans on 2018-05-31T07:22:31 (imported from GitLab project)
Please register or sign in to reply