# Please improve the API of embedded migrations

**URL:** <https://discourse.diesel.rs/t/please-improve-the-api-of-embedded-migrations/74>\
**Category:** Diesel 2.0\
**Created:** [March 11, 2019, 10:13pm UTC](https://discourse.diesel.rs/t/please-improve-the-api-of-embedded-migrations/74 "2019-03-11T22:13:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boscop](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@Boscop](https://discourse.diesel.rs/u/Boscop)\
**Post date:** [March 11, 2019, 10:13pm UTC](https://discourse.diesel.rs/t/please-improve-the-api-of-embedded-migrations/74/1 "2019-03-11T22:13:20Z")

</div>

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.
