feat(migrations): fix automation tables migration for idempotency#1458
Conversation
- Updated migration script to ensure ENUM types and tables are created only if they do not already exist, preventing errors on re-runs. - Added 'IF NOT EXISTS' clauses to table and index creation statements for improved safety during migrations. - Ensured that the migration can be safely re-applied without causing conflicts or failures.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis Alembic migration adds three automation persistence tables with idempotent creation logic. ENUM types are guarded with ChangesAutomation persistence schema
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR makes the automation tables migration script idempotent by adding conditional checks to prevent errors when the migration is re-run. The changes wrap ENUM type creation in
DO $$ BEGIN ... END $$blocks withIF NOT EXISTSchecks, and addIF NOT EXISTSclauses to allCREATE TABLEandCREATE INDEXstatements. This ensures that if a migration partially completes and fails, it can be safely re-applied without causing conflicts or duplicate object errors in PostgreSQL.⏱️ Estimated Review Time: 15-30 minutes
💡 Review Order Suggestion
surfsense_backend/alembic/versions/144_add_automation_tables.pySummary by CodeRabbit
New Features
Chores