New UI Features for Schema Tracking and Migration Management in ActualDbSchema
- View Schema with Migration Annotations in the UI
- Clean Up Broken Migrations
- Filter Migrations in the UI
- Customize Your Migrated Folder Location
- Conclusion
Hello, Rails developers! We’re thrilled to announce the release of ActualDbSchema v0.8.3! 🎉 This update brings new tools to visualize schema changes directly in your browser, clean up broken migrations, and customize your workflow. Let’s explore what’s new!
View Schema with Migration Annotations in the UI
Ever wanted to inspect your schema and trace which migration introduced a specific change directly from the browser? Now you can!
Navigate to the migrations page (http://localhost:3000/rails/migrations
) and click the View Schema
button to see the schema diff rendered in the UI, annotated with the migrations that created each change. In case there is no pending changes, the UI shows the entire schema.
Key Features:
- Diff Highlighting: See schema changes alongside their originating migrations.
- Filtering: Search for specific tables using a built-in filter.
- Migration Links: Click any annotation to jump to the corresponding migration details.
Schema Page on the UI
Schema Page with Filter
Clean Up Broken Migrations
Managing old migrations can be challenging, especially when migration files go missing. In this release, we’ve introduced a Broken Versions page and rake tasks to clean up these records.
What Are Broken Migrations?
A migration is considered broken if it exists in the database but the corresponding file is missing. This can happen if migrations were deleted manually after being applied.
How to Delete Broken Migrations?
1️⃣ Using the UI
Navigate to the following URL in your web browser to see all broken migrations:
http://localhost:3000/rails/broken_versions
You can delete them individually or use the Delete All button to clean up everything at once.
2️⃣ Using a Rake Task
Run the following command to remove all broken migrations:
rake actual_db_schema:delete_broken_versions
To delete specific migrations, specify their versions:
rake actual_db_schema:delete_broken_versions["20250224103352 20250224103358"]
For multi-database applications, you can also specify the database:
rake actual_db_schema:delete_broken_versions["20250224103352 20250224103358", "primary"]
Filter Migrations in the UI
Tired of scrolling through hundreds of migrations? We’ve added a search bar to the migrations page, making it easy to find migrations by name or content. Whether you’re tracking down a specific change or reviewing past updates, finding what you need is now faster and more intuitive.
Customize Your Migrated Folder Location
By default, ActualDbSchema stores migration records in tmp/migrated
. Now you can customize this path to match your project structure:
1️⃣ Using Environment Variable
Set the environment variable ACTUAL_DB_SCHEMA_MIGRATED_FOLDER
to your desired folder path:
export ACTUAL_DB_SCHEMA_MIGRATED_FOLDER="custom/migrated"
2️⃣ Using Initializer
Add the following line to your initializer file (config/initializers/actual_db_schema.rb
):
config.migrated_folder = Rails.root.join("custom", "migrated")
Conclusion
With ActualDbSchema v0.8.3, managing your database schema is easier than ever. From visualizing schema changes to cleaning up broken migrations and filtering migrations more efficiently, this release provides new tools for your Rails projects.
We hope these enhancements improve your development workflow. Give them a try in your next project and let us know what you think!
Happy coding, and stay tuned for more updates! 🌟