1use std::future::Future;
2use std::pin::Pin;
3
4pub(crate) mod migration_entity {
6 use sea_orm::entity::prelude::*;
7
8 #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
9 #[sea_orm(table_name = "_modo_migrations")]
10 pub struct Model {
11 #[sea_orm(primary_key, auto_increment = false)]
12 pub version: i64,
13 pub description: String,
14 pub executed_at: String,
15 }
16
17 #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
18 pub enum Relation {}
19
20 impl ActiveModelBehavior for ActiveModel {}
21}
22
23pub type MigrationFn = fn(
29 &sea_orm::DatabaseConnection,
30) -> Pin<Box<dyn Future<Output = Result<(), modo::Error>> + Send + '_>>;
31
32pub struct MigrationRegistration {
38 pub version: u64,
39 pub description: &'static str,
40 pub handler: MigrationFn,
41}
42
43inventory::collect!(MigrationRegistration);
44
45inventory::submit! {
47 crate::EntityRegistration {
48 table_name: "_modo_migrations",
49 register_fn: |sb| sb.register(migration_entity::Entity),
50 is_framework: true,
51 extra_sql: &[],
52 }
53}