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 group: &'static str,
41 pub handler: MigrationFn,
42}
43
44inventory::collect!(MigrationRegistration);
45
46inventory::submit! {
48 crate::EntityRegistration {
49 table_name: "_modo_migrations",
50 group: "default",
51 register_fn: |sb| sb.register(migration_entity::Entity),
52 is_framework: true,
53 extra_sql: &[],
54 }
55}