You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
During development, it's common to iteratively build up a schema migration while adding multiple tables for a new feature. Currently, without an ability to rollback a migration, the only options are to create many small migrations (which greatly bloats a codebase) or manually remove any tables / columns added by the migration before deleting and recreating.
Describe the solution you'd like
It would be nice if migrations were generated with a rollback.sql file which could be executed if the developer indicates a specific target migration from their history.
Which would rollback [timestamp-02]-first-feature, allowing the developer to delete that directory, update their models' yaml files, and recreate the migration.
Additional considerations
Obviously, this feature would require additional logic to generate the DROP TABLE or ALTER SCHEMA [table] DROP [columns] queries, but I think this would be quite valuable.
Activity
SandPod commentedon May 6, 2024
The developer experience around this could be significantly improved with a dedicated rollback feature.
Currently, support for rolling back migrations is done by utilizing repair migrations. This is documented here: https://docs.serverpod.dev/concepts/database/migrations#rolling-back-migrations
Repair migrations can target a specific migration version using the
--versionoption documented here: https://docs.serverpod.dev/concepts/database/migrations#targeting-a-specific-migrationAdamMusa commentedon May 18, 2024
Hey there, @craiglabenz and @SandPod I added some features here #2202