Please improve the API of embedded migrations


#1

The current API for embedded migrations is not sufficient for our needs:

Our multi-tenant project embeds two sets of migration files via the embed_migrations macro:

  • global migrations (for the global database)
  • org migrations (for organizations)

All organizations have the same tables, but in their own schema and possibly on different db instances (distributed storage servers).
We have functions to migrate the global database and to migrate a single organization.
Those functions should be able to not only run the embedded migrations, but also revert the latest embedded (!) migration.

When running migrations, those functions have to know:

  • the name and the output of all migrations that are run
  • if one migration fails:
    • how many migrations were run successfully before the one that failed (their names & output)
    • what was the name and db error of the first failing migration

When reverting the last embedded migration, those functions have to know the name and output of that migration, and the error if reverting fails.


E.g. currently, there doesn’t seem to be a way to revert the last embedded migration, the diesel_migrations::revert_latest_migration() function doesn’t use the embedded migrations.
And there is no way to get the output or name of that either.