Преглед изворни кода

Remove in-progress migration implementation.

Kestrel пре 1 недеља
родитељ
комит
5998372025
4 измењених фајлова са 5 додато и 141 уклоњено
  1. 0 1
      microrm/Cargo.toml
  2. 5 5
      microrm/src/lib.rs
  3. 0 3
      microrm/src/schema.rs
  4. 0 132
      microrm/tests/migration.rs

+ 0 - 1
microrm/Cargo.toml

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

+ 5 - 5
microrm/src/lib.rs

@@ -3,14 +3,14 @@
 //! Unlike many fancier ORM systems, microrm is designed to be lightweight, both in terms of
 //! runtime overhead and developer LoC. By necessity, it sacrifices flexibility towards these
 //! goals, and so can be thought of as more opinionated than, say,
-//! [SeaORM](https://www.sea-ql.org/SeaORM/) or [Diesel](https://diesel.rs/). The major limitation of
-//! microrm is somewhat limited vocabulary for describing object-to-object relations, though it is
-//! powerful enough for most usecases where sqlite is appropriate.
+//! [SeaORM](https://www.sea-ql.org/SeaORM/) or [Diesel](https://diesel.rs/). The major limitations
+//! of microrm are lack of migrations (though support is planned!) and somewhat limited vocabulary
+//! for describing object-to-object relations. Despite this, microrm is usually powerful enough for
+//! most usecases where sqlite is appropriate.
 //!
 //! There are three externally-facing components in microrm:
 //! - Schema modelling (mostly by the [`Datum`](schema/datum/trait.Datum.html) and
-//!   [`Entity`](schema/entity/trait.Entity.html) traits) and migrations (see
-//!   [`schema::migration::Migrator`]
+//!   [`Entity`](schema/entity/trait.Entity.html) traits)
 //! - Database querying (via [`query::Queryable`], [`query::RelationInterface`] and
 //!   [`query::Insertable`] traits)
 //! - Command-line interface generation via the [`clap`](https://docs.rs/clap/latest/clap/) crate

+ 0 - 3
microrm/src/schema.rs

@@ -28,9 +28,6 @@ pub mod relation;
 /// Types related to indexes.
 pub mod index;
 
-#[cfg(feature = "migrate")]
-pub mod migrate;
-
 mod build;
 mod collect;
 pub(crate) mod meta;

+ 0 - 132
microrm/tests/migration.rs

@@ -1,132 +0,0 @@
-#![cfg(feature = "migrate")]
-
-use microrm::{
-    prelude::*,
-    schema::migrate::{Migration, Migrator},
-    ConnectionPool,
-};
-use test_log::test;
-
-mod common;
-
-mod s1 {
-    use microrm::prelude::*;
-    #[derive(Entity)]
-    pub struct E {
-        pub val: String,
-    }
-
-    #[derive(Default, Schema)]
-    pub struct S {
-        pub emap: microrm::IDMap<E>,
-    }
-}
-use s1::{E as E1, S as S1};
-
-mod s2 {
-    use microrm::prelude::*;
-    #[derive(PartialEq, Entity)]
-    pub struct E {
-        pub val: String,
-        pub other_val: String,
-    }
-
-    #[derive(Default, Schema)]
-    pub struct S {
-        pub emap: microrm::IDMap<E>,
-    }
-}
-use s2::{E as E2, S as S2};
-
-#[derive(Default)]
-struct S1S2;
-
-impl Migration for S1S2 {
-    type OldSchema = S1;
-    type NewSchema = S2;
-}
-
-#[test]
-fn from_empty() {
-    let cpool = common::open_test_pool!();
-    let mut lease = cpool.acquire().unwrap();
-
-    let mut migrator = Migrator::new::<S1>();
-    migrator.add::<S1S2>();
-
-    migrator.apply(&mut lease).unwrap();
-}
-
-#[test]
-fn multistep_schema() {
-    let cpool = common::open_test_pool!();
-    let mut lease = cpool.acquire().unwrap();
-
-    // first apply S1
-    let mut migrator = Migrator::new::<S1>();
-    migrator.apply(&mut lease).unwrap();
-
-    // then apply S1S2
-    migrator.add::<S1S2>();
-    migrator.apply(&mut lease).unwrap();
-
-    S2::default()
-        .emap
-        .insert(
-            &mut lease,
-            E2 {
-                val: String::from("some_val"),
-                other_val: String::from("some_other_val"),
-            },
-        )
-        .unwrap();
-
-    let all_entities = S2::default().emap.get(&mut lease).unwrap();
-    assert_eq!(
-        all_entities
-            .into_iter()
-            .map(|v| v.wrapped())
-            .collect::<Vec<_>>(),
-        vec![E2 {
-            val: String::from("some_val"),
-            other_val: String::from("some_other_val")
-        },]
-    );
-}
-
-#[test]
-fn migrated_data() {
-    let cpool = common::open_test_pool!(); // ConnectionPool::new(":memory:").unwrap();
-    let mut lease = cpool.acquire().unwrap();
-
-    // first apply S1
-    let mut migrator = Migrator::new::<S1>();
-    migrator.apply(&mut lease).unwrap();
-
-    // add some data
-    S1::default()
-        .emap
-        .insert(
-            &mut lease,
-            E1 {
-                val: String::from("some_val"),
-            },
-        )
-        .unwrap();
-
-    // then apply S1S2
-    migrator.add::<S1S2>();
-    migrator.apply(&mut lease).unwrap();
-
-    let all_entities = S2::default().emap.get(&mut lease).unwrap();
-    assert_eq!(
-        all_entities
-            .into_iter()
-            .map(|v| v.wrapped())
-            .collect::<Vec<_>>(),
-        vec![E2 {
-            val: String::from("some_val"),
-            other_val: String::from("migrated_value")
-        },]
-    );
-}