-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stages_enabled column fixes * custom_stages fixes * validate custom stages array in API * fix client/API custom stages * type fixes * fix migration * disallow single quotes in validation * remove quote replacement
- Loading branch information
1 parent
3f74acf
commit 18bd067
Showing
10 changed files
with
186 additions
and
21 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
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
160 changes: 160 additions & 0 deletions
160
packages/commonwealth/server/migrations/20240213234425-standard-custom-stages.js
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,160 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.addColumn( | ||
'Communities', | ||
'temp_stages_enabled', | ||
{ | ||
type: Sequelize.BOOLEAN, | ||
defaultValue: true, | ||
}, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_stages_enabled = CASE | ||
WHEN stages_enabled = 'true' THEN TRUE | ||
ELSE FALSE | ||
END; | ||
`, | ||
{ | ||
transaction, | ||
}, | ||
); | ||
|
||
await queryInterface.removeColumn('Communities', 'stages_enabled', { | ||
transaction, | ||
}); | ||
await queryInterface.renameColumn( | ||
'Communities', | ||
'temp_stages_enabled', | ||
'stages_enabled', | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
ALTER TABLE "Communities" | ||
ADD COLUMN temp_custom_stages TEXT[]; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"In Discussion","In Voting","Voting Ended"}' | ||
WHERE id = 'shell-protocol' AND custom_stages = '["In Discussion","In Voting","Voting Ended"}'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"In Discussion", "Passed"}' | ||
WHERE id = 'aavegotchi' AND custom_stages = '[In Discussion, Passed]'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"In Discussion", "Passed"}' | ||
WHERE id = 'cerberus-zone' AND custom_stages = '["In Discussion, Passed"]'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"Temperature Check", "Discussion", "Voting", "Passed", "Failed"}' | ||
WHERE id = 'dao-masons' AND custom_stages = '["Temperature Check" "Discussion" "Voting" "Passed" "Failed"]'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"Stage 1", "Stage 2", "Stage 3"}' | ||
WHERE id = 'my-first-community' AND custom_stages = '"Stage 1", "Stage 2", "Stage 3"'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"In Discussion", "Voting", "Ended"}' | ||
WHERE id = 'talis' AND custom_stages = '"In Discussion","Voting","Ended"'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"chat", "Stage 2", "Stage 3"}' | ||
WHERE id = 'artrate' AND custom_stages = '["chat", "Stage 2", "Stage 3",…]'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = '{"Stage 1", "Stage 2", "Final Stage"}' | ||
WHERE id = 'matic-token' AND custom_stages = '[ "Stage 1", "Stage 2", "Final Stage" ]'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Communities" | ||
SET temp_custom_stages = CASE | ||
WHEN custom_stages IS NULL OR custom_stages = '' OR custom_stages IN ('true', 'false') | ||
THEN '{}' | ||
ELSE ( | ||
SELECT ARRAY( | ||
SELECT json_array_elements_text(custom_stages::json) | ||
) | ||
) | ||
END | ||
WHERE temp_custom_stages IS NULL; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.sequelize.query( | ||
` | ||
ALTER TABLE "Communities" | ||
ALTER COLUMN "temp_custom_stages" SET DEFAULT '{}'; | ||
`, | ||
{ transaction }, | ||
); | ||
|
||
await queryInterface.removeColumn('Communities', 'custom_stages', { | ||
transaction, | ||
}); | ||
|
||
await queryInterface.renameColumn( | ||
'Communities', | ||
'temp_custom_stages', | ||
'custom_stages', | ||
{ transaction }, | ||
); | ||
}); | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
// irreversible | ||
}, | ||
}; |
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