-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/scripts/U3_5_0_7__remove_duplicate_users.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- no rollback script for this |
1 change: 1 addition & 0 deletions
1
src/main/resources/scripts/U3_5_0_8__make_account_name_unique.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP INDEX IF EXISTS users_account_name_unique_index; |
42 changes: 42 additions & 0 deletions
42
src/main/resources/scripts/V3_5_0_7__remove_duplicate_users.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
ALTER TABLE acceptances DROP CONSTRAINT acceptances_leader_id_fkey; | ||
ALTER TABLE acceptances ADD CONSTRAINT acceptances_leader_id_fkey FOREIGN KEY (leader_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE acceptances DROP CONSTRAINT acceptances_request_id_fkey; | ||
ALTER TABLE acceptances ADD CONSTRAINT acceptances_request_id_fkey FOREIGN KEY (request_id) REFERENCES requests(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE automatic_vacation_days DROP CONSTRAINT automatic_vacation_days_user_id_fkey; | ||
ALTER TABLE automatic_vacation_days ADD CONSTRAINT automatic_vacation_days_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE history_logs DROP CONSTRAINT history_logs_user_id_fkey; | ||
ALTER TABLE history_logs ADD CONSTRAINT history_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE history_logs DROP CONSTRAINT history_logs_decider_id_fkey; | ||
ALTER TABLE history_logs ADD CONSTRAINT history_logs_decider_id_fkey FOREIGN KEY (decider_id) REFERENCES users(id) ON DELETE SET NULL; | ||
|
||
ALTER TABLE history_logs DROP CONSTRAINT history_logs_prev_history_log_id_fkey; | ||
ALTER TABLE history_logs ADD CONSTRAINT history_logs_prev_history_log_id_fkey FOREIGN KEY (prev_history_log_id) REFERENCES history_logs(id) ON DELETE SET NULL; | ||
|
||
ALTER TABLE history_logs DROP CONSTRAINT history_logs_request_id_fkey; | ||
ALTER TABLE history_logs ADD CONSTRAINT history_logs_request_id_fkey FOREIGN KEY (request_id) REFERENCES requests(id) ON DELETE SET NULL; | ||
|
||
ALTER TABLE presence_confirmations DROP CONSTRAINT presence_confirmations_user_id_fkey; | ||
ALTER TABLE presence_confirmations ADD CONSTRAINT presence_confirmations_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE requests DROP CONSTRAINT requests_requester_id_fkey; | ||
ALTER TABLE requests ADD CONSTRAINT requests_requester_id_fkey FOREIGN KEY (requester_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE teams DROP CONSTRAINT teams_leader_id_fkey; | ||
ALTER TABLE teams ADD CONSTRAINT teams_leader_id_fkey FOREIGN KEY (leader_id) REFERENCES users(id) ON DELETE SET NULL; | ||
|
||
ALTER TABLE user_working_hours_preference DROP CONSTRAINT user_working_hours_preference_user_id_fkey; | ||
ALTER TABLE user_working_hours_preference ADD CONSTRAINT user_working_hours_preference_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE users_teams DROP CONSTRAINT users_teams_user_id_fkey; | ||
ALTER TABLE users_teams ADD CONSTRAINT users_teams_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE users_teams DROP CONSTRAINT users_teams_team_id_fkey; | ||
ALTER TABLE users_teams ADD CONSTRAINT users_teams_team_id_fkey FOREIGN KEY (team_id) REFERENCES teams(name) ON DELETE CASCADE; | ||
|
||
WITH CTE AS (SELECT id, ROW_NUMBER() OVER (PARTITION BY account_name ORDER BY id) AS rn FROM users) | ||
DELETE FROM users | ||
WHERE id IN (SELECT id FROM CTE WHERE rn > 1); |
3 changes: 3 additions & 0 deletions
3
src/main/resources/scripts/V3_5_0_8__make_account_name_unique.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE UNIQUE INDEX users_account_name_unique_index | ||
ON users (account_name) | ||
WHERE account_name IS NOT NULL; |