소스 검색

Moved migration behind feature gate, fixed tests.

Kestrel 2 주 전
부모
커밋
5b90239bec
6개의 변경된 파일8개의 추가작업 그리고 13개의 파일을 삭제
  1. 1 1
      microrm-macros/src/schema.rs
  2. 1 0
      microrm/Cargo.toml
  3. 1 0
      microrm/src/schema.rs
  4. 1 1
      microrm/src/schema/migration.rs
  5. 2 11
      microrm/tests/manual_construction.rs
  6. 2 0
      microrm/tests/migration.rs

+ 1 - 1
microrm-macros/src/schema.rs

@@ -45,7 +45,7 @@ pub fn derive(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
         let item_type = &field.1;
 
         quote! {
-            <#item_type as Default>::default().accept_item_visitor(v);
+            <#item_type as ::microrm::schema::DatabaseItem>::accept_item_visitor(&<#item_type as Default>::default(), v);
         }
     });
 

+ 1 - 0
microrm/Cargo.toml

@@ -16,6 +16,7 @@ all-features = true
 [features]
 clap = ["dep:clap"]
 bundled_sqlite = ["libsqlite3-sys/bundled"]
+unstable_migration = []
 
 [dependencies]
 libsqlite3-sys = "0.28"

+ 1 - 0
microrm/src/schema.rs

@@ -28,6 +28,7 @@ pub mod relation;
 /// Types related to indexes.
 pub mod index;
 
+#[cfg(feature = "unstable_migration")]
 pub mod migration;
 
 mod build;

+ 1 - 1
microrm/src/schema/migration.rs

@@ -8,7 +8,7 @@ use std::collections::HashSet;
 use crate::{
     db::ConnectionLease,
     query::Queryable,
-    schema::{entity::EntityList, Schema},
+    schema::Schema,
     DBResult,
 };
 

+ 2 - 11
microrm/tests/manual_construction.rs

@@ -126,20 +126,11 @@ struct SimpleDatabase {
 }
 
 impl Schema for SimpleDatabase {
-    fn build() -> Self
+    fn accept_item_visitor(&self, visitor: &mut impl DatabaseItemVisitor)
     where
         Self: Sized,
     {
-        Self {
-            strings: IDMap::build(),
-        }
-    }
-
-    fn accept_item_visitor(visitor: &mut impl DatabaseItemVisitor)
-    where
-        Self: Sized,
-    {
-        <IDMap<SimpleEntity> as DatabaseItem>::accept_item_visitor(visitor);
+        <IDMap<SimpleEntity> as DatabaseItem>::accept_item_visitor(&IDMap::default(), visitor);
     }
 }
 

+ 2 - 0
microrm/tests/migration.rs

@@ -1,3 +1,5 @@
+#![cfg(feature = "unstable_migration")]
+
 use microrm::{
     prelude::*,
     schema::migration::{Migration, Migrator},