Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP0universalStack: sql
migrationsdata-lossdatabasereversibility
A migration's down() must reverse exactly what up() did, not drop the whole table
When a migration adds columns, its down() should remove only those columns; dropping the entire table (or otherwise over-reverting) destroys unrelated data.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codejavascript
| 1 | async down(queryInterface) { |
| 2 | await queryInterface.dropTable('posts'); // up() only added 2 columns! |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | async down(queryInterface) { |
| 2 | await queryInterface.removeColumn('posts', 'upvotecount'); |
| 3 | await queryInterface.removeColumn('posts', 'downvotecount'); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)