-
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.
Merge pull request #8994 from hicommonwealth/8990.jake.remove-bans-table
Eliminate Bans table.
- Loading branch information
Showing
19 changed files
with
105 additions
and
112 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 was deleted.
Oops, something went wrong.
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
74 changes: 74 additions & 0 deletions
74
packages/commonwealth/server/migrations/20240826192720-remove-bans-table.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,74 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.addColumn( | ||
'Addresses', | ||
'is_banned', | ||
{ | ||
type: Sequelize.BOOLEAN, | ||
allowNull: false, | ||
defaultValue: false, | ||
}, | ||
{ transaction }, | ||
); | ||
await queryInterface.sequelize.query( | ||
` | ||
UPDATE "Addresses" AS a | ||
SET is_banned = true | ||
FROM "Bans" b | ||
WHERE a.address = b.address AND a.community_id = b.community_id; | ||
`, | ||
{ | ||
transaction, | ||
}, | ||
); | ||
await queryInterface.dropTable('Bans', { transaction }); | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
return queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.createTable( | ||
'Bans', | ||
{ | ||
id: { | ||
type: Sequelize.INTEGER, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
}, | ||
address: { type: Sequelize.STRING, allowNull: false }, | ||
community_id: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
references: { model: 'Communities', key: 'id' }, | ||
}, | ||
created_at: { type: Sequelize.DATE, allowNull: false }, | ||
updated_at: { type: Sequelize.DATE, allowNull: false }, | ||
}, | ||
{ | ||
timestamps: true, | ||
underscored: true, | ||
indexes: [{ fields: ['community_id'] }], | ||
transaction, | ||
}, | ||
); | ||
await queryInterface.sequelize.query( | ||
` | ||
INSERT INTO "Bans" (address, community_id, created_at, updated_at) | ||
SELECT address, community_id, NOW(), NOW() | ||
FROM "Addresses" | ||
WHERE is_banned = true; | ||
`, | ||
{ | ||
transaction, | ||
}, | ||
); | ||
await queryInterface.removeColumn('Addresses', 'is_banned', { | ||
transaction, | ||
}); | ||
}); | ||
}, | ||
}; |
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 was deleted.
Oops, something went wrong.
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