♻️ Removed Makefile, refactored schema in tests
Some checks failed
Build & test / build (push) Has been cancelled
Some checks failed
Build & test / build (push) Has been cancelled
This commit is contained in:
parent
d260b2d676
commit
f14543af6b
@ -6,7 +6,7 @@ exclude = ["examples"]
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
authors = ["Martin Berg Alstad"]
|
authors = ["Martin Berg Alstad"]
|
||||||
homepage = "emberal.github.io"
|
homepage = "martials.no"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "lib"
|
name = "lib"
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
[tasks.clippy]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
|
||||||
|
|
||||||
[tasks.fmt]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["fmt", "--all"]
|
|
||||||
|
|
||||||
[tasks.test]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["test", "--all-features"]
|
|
||||||
|
|
||||||
[tasks.coverage]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["llvm-cov", "--all-features"]
|
|
@ -2,7 +2,7 @@
|
|||||||
# see https://diesel.rs/guides/configuring-diesel-cli
|
# see https://diesel.rs/guides/configuring-diesel-cli
|
||||||
|
|
||||||
[print_schema]
|
[print_schema]
|
||||||
file = "src/schema.rs"
|
file = "tests/schema.rs"
|
||||||
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
|
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
|
||||||
|
|
||||||
[migrations_directory]
|
[migrations_directory]
|
||||||
|
@ -5,15 +5,9 @@ use lib::diesel_crud_derive::{
|
|||||||
use lib::diesel_crud_trait::DieselCrudCreate;
|
use lib::diesel_crud_trait::DieselCrudCreate;
|
||||||
use test_containers::create_test_containers_pool;
|
use test_containers::create_test_containers_pool;
|
||||||
|
|
||||||
|
mod schema;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod test_containers;
|
mod test_containers;
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
user (email) {
|
|
||||||
#[max_length = 255]
|
|
||||||
email -> Varchar,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
@ -29,14 +23,14 @@ diesel::table! {
|
|||||||
DieselCrudUpdate,
|
DieselCrudUpdate,
|
||||||
)]
|
)]
|
||||||
#[diesel_crud(insert = InsertUser)]
|
#[diesel_crud(insert = InsertUser)]
|
||||||
#[diesel(table_name = user)]
|
#[diesel(table_name = schema::user)]
|
||||||
struct User {
|
struct User {
|
||||||
#[diesel_crud(pk)]
|
#[diesel_crud(pk)]
|
||||||
email: String,
|
email: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Insertable)]
|
#[derive(Clone, Insertable)]
|
||||||
#[diesel(table_name = user)]
|
#[diesel(table_name = schema::user)]
|
||||||
struct InsertUser {
|
struct InsertUser {
|
||||||
email: String,
|
email: String,
|
||||||
}
|
}
|
||||||
|
6
crates/tests/tests/schema.rs
Normal file
6
crates/tests/tests/schema.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
diesel::table! {
|
||||||
|
user (email) {
|
||||||
|
#[max_length = 255]
|
||||||
|
email -> Varchar,
|
||||||
|
}
|
||||||
|
}
|
4
justfile
4
justfile
@ -4,10 +4,10 @@ run:
|
|||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
cargo fmt
|
cargo fmt --all
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
cargo clippy
|
cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
release:
|
release:
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
@ -13,8 +13,7 @@ pub async fn run_migrations<A>(
|
|||||||
where
|
where
|
||||||
A: AsyncConnection<Backend = Pg> + 'static,
|
A: AsyncConnection<Backend = Pg> + 'static,
|
||||||
{
|
{
|
||||||
let mut async_wrapper: AsyncConnectionWrapper<A> =
|
let mut async_wrapper = AsyncConnectionWrapper::<A>::from(async_connection);
|
||||||
AsyncConnectionWrapper::from(async_connection);
|
|
||||||
|
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
async_wrapper.run_pending_migrations(migrations).unwrap();
|
async_wrapper.run_pending_migrations(migrations).unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user