Allow migrations to have attached metadata, avoid running in transaction

On PostgreSQL, certain commands cannot be run inside of a transaction,
such as `CREATE INDEX CONCURRENTLY` and `ALTER TYPE`. This causes
problems when attempting to use Diesel migrations, since we always run
these migrations inside a transaction.

To allow opting out of this, we introduce the concept of migration
metadata. I've opted to keep this incredibly general, rather than adding
a specific `should_run_in_migration` function, as there's been interest
expressed in having this capability to enable alternate migration
runners.

Since we need to retain object safety, we can't actually have any
defined structure for the metadata. The best we can do is either
something that is conceptually `Map<String, String>`, or an enum like
`serde_json::Value` or `toml::Value`. I really don't want to restrict
what can or cannot be in here, so I've opted for the more general
option.
8 files changed
tree: a8cfbe2be8e9f64a3cfe9c5b4ab96f04319c41a9
  1. .github/
  2. bin/
  3. diesel/
  4. diesel_cli/
  5. diesel_compile_tests/
  6. diesel_derives/
  7. diesel_infer_schema/
  8. diesel_migrations/
  9. diesel_tests/
  10. examples/
  11. guide_drafts/
  12. migrations/
  13. .appveyor.yml
  14. .editorconfig
  15. .env.sample
  16. .gitignore
  17. .rustfmt.toml
  18. .travis.yml
  19. Cargo.toml
  20. CHANGELOG.md
  21. clippy.toml
  22. code_of_conduct.md
  23. CONTRIBUTING.md
  24. LICENSE-APACHE
  25. LICENSE-MIT
  26. README.md
README.md

A safe, extensible ORM and Query Builder for Rust

Build Status Appveyor Build Status Gitter Crates.io

API Documentation: latest releasemaster branch

Homepage

Diesel gets rid of the boilerplate for database interaction and eliminates runtime errors without sacrificing performance. It takes full advantage of Rust's type system to create a low overhead query builder that “feels like Rust.”

Getting Started

Find our extensive Getting Started tutorial at https://diesel.rs/guides/getting-started. Guides on more specific features are coming soon.

Code of conduct

Anyone who interacts with Diesel in any space, including but not limited to this GitHub repository, must follow our code of conduct.

License

Licensed under either of these:

Contributing

Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.