| 1 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 2 | use craterust-analyzer cargo sqlx-core 0.8.3 crate/::migraterust-analyzer cargo sqlx-core 0.8.3 migrate/::{AppliedMigrationrust-analyzer cargo sqlx-core 0.8.3 migrate/migration/AppliedMigration#, MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#, Migrationrust-analyzer cargo sqlx-core 0.8.3 migrate/migration/Migration#}; |
| 3 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::futurerust-analyzer cargo futures-core 0.3.34 future/::BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#; |
| 5 | |
| 6 | pub trait MigrateDatabaserust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/MigrateDatabase# { |
| 7 | // create database in url |
| 8 | // uses a maintenance database depending on driver |
| 9 | fn create_databaserust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/MigrateDatabase#create_database().(url: &str) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 10 | |
| 11 | // check if the database in url exists |
| 12 | // uses a maintenance database depending on driver |
| 13 | fn database_existsrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/MigrateDatabase#database_exists().(url: &str) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 14 | |
| 15 | // drop database in url |
| 16 | // uses a maintenance database depending on driver |
| 17 | fn drop_databaserust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/MigrateDatabase#drop_database().(url: &str) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>; |
| 18 | |
| 19 | // force drop database in url |
| 20 | // uses a maintenance database depending on driver |
| 21 | fn force_drop_databaserust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/MigrateDatabase#force_drop_database().(_url: &str) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 22 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(async { Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#::ForceNotSupportedrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#ForceNotSupported#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). }) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // 'e = Executor |
| 27 | pub trait Migraterust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate# { |
| 28 | // ensure migrations table exists |
| 29 | // will create or migrate it if needed |
| 30 | fn ensure_migrations_tablerust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#ensure_migrations_table().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 31 | |
| 32 | // Return the version on which the database is dirty or None otherwise. |
| 33 | // "dirty" means there is a partially applied migration that failed. |
| 34 | fn dirty_versionrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#dirty_version().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i64>, MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 35 | |
| 36 | // Return the ordered list of applied migrations |
| 37 | fn list_applied_migrationsrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#list_applied_migrations().( |
| 38 | &mut self, |
| 39 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<AppliedMigrationrust-analyzer cargo sqlx-core 0.8.3 migrate/migration/AppliedMigration#>, MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 40 | |
| 41 | // Should acquire a database lock so that only one migration process |
| 42 | // can run at a time. [`Migrate`] will call this function before applying |
| 43 | // any migrations. |
| 44 | fn lockrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#lock().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 45 | |
| 46 | // Should release the lock. [`Migrate`] will call this function after all |
| 47 | // migrations have been run. |
| 48 | fn unlockrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#unlock().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 49 | |
| 50 | // run SQL from migration in a DDL transaction |
| 51 | // insert new row to [_migrations] table on completion (success or failure) |
| 52 | // returns the time taking to run the migration SQL |
| 53 | fn applyrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#apply().<'e: 'm, 'm>( |
| 54 | &'e mut self, |
| 55 | migration: &'m Migrationrust-analyzer cargo sqlx-core 0.8.3 migrate/migration/Migration#, |
| 56 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'m, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 57 | |
| 58 | // run a revert SQL from migration in a DDL transaction |
| 59 | // deletes the row in [_migrations] table with specified migration version on completion (success or failure) |
| 60 | // returns the time taking to run the migration SQL |
| 61 | fn revertrust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate#revert().<'e: 'm, 'm>( |
| 62 | &'e mut self, |
| 63 | migration: &'m Migrationrust-analyzer cargo sqlx-core 0.8.3 migrate/migration/Migration#, |
| 64 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'m, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, MigrateErrorrust-analyzer cargo sqlx-core 0.8.3 migrate/error/MigrateError#>>; |
| 65 | } |