mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
Drop and re-add columns instead.
This commit is contained in:
parent
89d5627963
commit
6efd025470
2 changed files with 16 additions and 18 deletions
|
@ -1,6 +1,10 @@
|
||||||
ALTER TABLE local_user_vote_display_mode
|
ALTER TABLE local_user_vote_display_mode
|
||||||
ALTER COLUMN upvotes SET DEFAULT FALSE,
|
DROP COLUMN score,
|
||||||
ALTER COLUMN downvotes SET DEFAULT FALSE,
|
ADD COLUMN score boolean DEFAULT TRUE NOT NULL,
|
||||||
ALTER COLUMN score SET DEFAULT TRUE,
|
DROP COLUMN upvotes,
|
||||||
ALTER COLUMN upvote_percentage SET DEFAULT TRUE;
|
ADD COLUMN upvotes boolean DEFAULT FALSE NOT NULL,
|
||||||
|
DROP COLUMN downvotes,
|
||||||
|
ADD COLUMN downvotes boolean DEFAULT FALSE NOT NULL,
|
||||||
|
DROP COLUMN upvote_percentage,
|
||||||
|
ADD COLUMN upvote_percentage boolean DEFAULT TRUE NOT NULL;
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,12 @@
|
||||||
-- Rather than
|
-- Rather than
|
||||||
-- Score + upvote_percentage
|
-- Score + upvote_percentage
|
||||||
ALTER TABLE local_user_vote_display_mode
|
ALTER TABLE local_user_vote_display_mode
|
||||||
ALTER COLUMN upvotes SET DEFAULT TRUE,
|
DROP COLUMN score,
|
||||||
ALTER COLUMN downvotes SET DEFAULT TRUE,
|
ADD COLUMN score boolean DEFAULT FALSE NOT NULL,
|
||||||
ALTER COLUMN score SET DEFAULT FALSE,
|
DROP COLUMN upvotes,
|
||||||
ALTER COLUMN upvote_percentage SET DEFAULT FALSE;
|
ADD COLUMN upvotes boolean DEFAULT TRUE NOT NULL,
|
||||||
|
DROP COLUMN downvotes,
|
||||||
-- Regenerate the rows with the new default
|
ADD COLUMN downvotes boolean DEFAULT TRUE NOT NULL,
|
||||||
DELETE FROM local_user_vote_display_mode;
|
DROP COLUMN upvote_percentage,
|
||||||
|
ADD COLUMN upvote_percentage boolean DEFAULT FALSE NOT NULL;
|
||||||
-- Re-insert them
|
|
||||||
INSERT INTO local_user_vote_display_mode (local_user_id)
|
|
||||||
SELECT
|
|
||||||
id
|
|
||||||
FROM
|
|
||||||
local_user;
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue