Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,5 @@ jobs:
components: clippy, rustfmt
target: wasm32-unknown-unknown

- name: Install Cargo Binary Install
uses: cargo-bins/cargo-binstall@main

- name: Install crates
run: cargo binstall -y sea-orm-cli

- name: Test
run: cargo test --locked --release
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ shield-axum = { workspace = true, features = ["utoipa"] }
shield-memory = { workspace = true, features = ["method-oidc"] }
shield-oidc = { workspace = true, features = ["native-tls"] }
time = "0.3.37"
tokio = { workspace = true, features = ["rt-multi-thread"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tower-sessions.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion examples/dioxus-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ shield-dioxus.workspace = true
shield-dioxus-axum = { workspace = true, optional = true }
shield-memory = { workspace = true, optional = true }
shield-oidc = { workspace = true, features = ["native-tls"], optional = true }
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
], optional = true }
tower-sessions = { workspace = true, optional = true }
tracing.workspace = true
5 changes: 4 additions & 1 deletion examples/leptos-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ shield-leptos-axum = { workspace = true, features = [
shield-memory = { workspace = true, optional = true }
shield-oidc = { workspace = true, features = ["native-tls"], optional = true }
time = "0.3.37"
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
], optional = true }
tower-sessions = { workspace = true, optional = true }
tracing.workspace = true
tracing-subscriber.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion examples/workos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ shield-dioxus.workspace = true
shield-dioxus-axum = { workspace = true, optional = true }
shield-memory = { workspace = true, optional = true }
shield-workos = { workspace = true, optional = true }
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
], optional = true }
tower-sessions = { workspace = true, optional = true }
tracing.workspace = true
7 changes: 7 additions & 0 deletions packages/storage/shield-sea-orm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ shield-oauth = { workspace = true, optional = true }
shield-oidc = { workspace = true, optional = true }
# shield-webauthn = { workspace = true, optional = true }
utoipa = { workspace = true, optional = true }

[dev-dependencies]
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
"test-util",
] }
69 changes: 20 additions & 49 deletions packages/storage/shield-sea-orm/tests/migration.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use std::{
env,
path::{Path, PathBuf},
process::Command,
};

fn example_path() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../examples/sea-orm")
}
use sea_orm::Database;
use sea_orm_migration::migrator::MigratorTrait;
use shield_sea_orm::migrations::Migrator;

const BACKENDS: &[(&str, &str)] = &[
("mysql", "mysql://shield:shield@localhost:13306/shield"),
Expand All @@ -17,49 +11,26 @@ const BACKENDS: &[(&str, &str)] = &[
("sqlite", "sqlite:///tmp/shield-seaorm.sqlite?mode=rwc"),
];

#[test]
pub fn migrations() {
#[tokio::test]
async fn migrations() {
for (backend, url) in BACKENDS {
// Check up migrations
assert!(
Command::new("sea-orm-cli")
.arg("migrate")
.arg("fresh")
.arg("-u")
.arg(url)
.arg("-d")
.arg(example_path())
.status()
.unwrap_or_else(|_| panic!("{backend} up migrations should succeed."))
.success()
);
let database = Database::connect(url.to_owned())
.await
.unwrap_or_else(|err| panic!("Connect to backend `{backend}` failed: {err}"));

// Up migrations
Migrator::fresh(&database)
.await
.unwrap_or_else(|err| panic!("Up migrations for backend `{backend}` failed: {err}"));

// Check down migrations
assert!(
Command::new("sea-orm-cli")
.arg("migrate")
.arg("refresh")
.arg("-u")
.arg(url)
.arg("-d")
.arg(example_path())
.status()
.unwrap_or_else(|_| panic!("{backend} down migrations should succeed."))
.success()
);
// Down migrations
Migrator::refresh(&database)
.await
.unwrap_or_else(|err| panic!("Down migrations for backend `{backend}` failed: {err}"));

// Cleanup
assert!(
Command::new("sea-orm-cli")
.arg("migrate")
.arg("reset")
.arg("-u")
.arg(url)
.arg("-d")
.arg(example_path())
.status()
.unwrap_or_else(|_| panic!("{backend} cleanup should succeed."))
.success()
);
Migrator::reset(&database)
.await
.unwrap_or_else(|err| panic!("Cleanup for backend `{backend}` failed: {err}"));
}
}