✨ Nix shell, pg docker, fix paths, replaced make with just
This commit is contained in:
parent
f7036a18a0
commit
e4024d05f9
5
.env
5
.env
@ -1 +1,4 @@
|
|||||||
DATABASE_URL="postgres://postgres:postgres@localhost:32784/postgres"
|
DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"
|
||||||
|
POSTGRES_DB=postgres
|
||||||
|
POSTGRES_USER=postgres
|
||||||
|
POSTGRES_PASSWORD=postgres
|
2
.idea/dataSources.xml
generated
2
.idea/dataSources.xml
generated
@ -5,7 +5,7 @@
|
|||||||
<driver-ref>postgresql</driver-ref>
|
<driver-ref>postgresql</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
<jdbc-url>jdbc:postgresql://localhost:32769/postgres</jdbc-url>
|
<jdbc-url>jdbc:postgresql://localhost:5432/postgres</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
@ -1512,7 +1512,6 @@ version = "1.4.3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
"bon",
|
|
||||||
"chrono",
|
"chrono",
|
||||||
"deadpool-diesel",
|
"deadpool-diesel",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
@ -2847,14 +2846,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-http"
|
name = "tower-http"
|
||||||
version = "0.6.1"
|
version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97"
|
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
@ -41,11 +41,11 @@ bon = "2.0.0"
|
|||||||
validator = { version = "0.18.1", features = ["derive"] }
|
validator = { version = "0.18.1", features = ["derive"] }
|
||||||
axum-valid = { version = "0.20.0", features = ["validator"] }
|
axum-valid = { version = "0.20.0", features = ["validator"] }
|
||||||
|
|
||||||
lib = { path = "../lib", features = ["axum", "serde", "derive", "diesel", "time"] }
|
lib = { path = "../rust-lib", features = ["axum", "serde", "derive", "diesel", "time"] }
|
||||||
#lib = { git = "https://github.com/emberal/rust-lib", tag = "1.4.3", features = ["axum", "serde", "derive"] }
|
#lib = { git = "https://github.com/emberal/rust-lib", tag = "1.4.3", features = ["axum", "serde", "derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
lib = { path = "../lib", features = ["test"] }
|
lib = { path = "../rust-lib", features = ["test"] }
|
||||||
rstest = "0.22.0"
|
rstest = "0.22.0"
|
||||||
testcontainers-modules = { version = "0.10.0", features = ["postgres"] }
|
testcontainers-modules = { version = "0.10.0", features = ["postgres"] }
|
||||||
async-std = { version = "1.12.0", features = ["attributes"] }
|
async-std = { version = "1.12.0", features = ["attributes"] }
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
[tasks.fmt]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["fmt"]
|
|
||||||
|
|
||||||
[tasks.lint]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["clippy"]
|
|
||||||
|
|
||||||
[tasks.release]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["build", "--release"]
|
|
||||||
|
|
||||||
[tasks.run_migrations]
|
|
||||||
command = "diesel"
|
|
||||||
args = ["migration", "run"]
|
|
||||||
|
|
||||||
[tasks.redo_migrations]
|
|
||||||
command = "diesel"
|
|
||||||
args = ["migration", "redo"]
|
|
||||||
|
|
||||||
[tasks.test]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["test", "--all-features"]
|
|
||||||
|
|
||||||
[tasks.coverage]
|
|
||||||
command = "cargo"
|
|
||||||
args = ["llvm-cov"]
|
|
@ -6,4 +6,4 @@ file = "src/schema.rs"
|
|||||||
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
|
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
|
||||||
|
|
||||||
[migrations_directory]
|
[migrations_directory]
|
||||||
dir = "/home/martin/git/rust/hotel_service/migrations"
|
dir = "./migrations"
|
||||||
|
9
docker-compose.yml
Normal file
9
docker-compose.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
database:
|
||||||
|
image: postgres:latest
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ${PWD}/db-data/:/var/lib/postgresql/data/
|
44
flake.lock
generated
Normal file
44
flake.lock
generated
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741048562,
|
||||||
|
"narHash": "sha256-W4YZ3fvWZiFYYyd900kh8P8wU6DHSiwaH0j4+fai1Sk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6af28b834daca767a7ef99f8a7defa957d0ade6f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-24.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-unstable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741010256,
|
||||||
|
"narHash": "sha256-WZNlK/KX7Sni0RyqLSqLPbK8k08Kq7H7RijPJbq9KHM=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "ba487dbc9d04e0634c64e3b1f0d25839a0a68246",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"nixpkgs-unstable": "nixpkgs-unstable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
38
flake.nix
Normal file
38
flake.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||||
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, nixpkgs-unstable, ... }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells.${system}.default =
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
unstable = import nixpkgs-unstable {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
git
|
||||||
|
just
|
||||||
|
] ++ [
|
||||||
|
# Rust
|
||||||
|
gcc
|
||||||
|
cargo
|
||||||
|
] ++ [
|
||||||
|
# Diesel
|
||||||
|
diesel-cli
|
||||||
|
unstable.libpq
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = "fish";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
23
justfile
Normal file
23
justfile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
run:
|
||||||
|
cargo run
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
cargo fmt
|
||||||
|
|
||||||
|
lint:
|
||||||
|
cargo clippy
|
||||||
|
|
||||||
|
release:
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
run_migrations:
|
||||||
|
diesel migration run
|
||||||
|
|
||||||
|
redo_migrations:
|
||||||
|
diesel migration redo
|
||||||
|
|
||||||
|
test:
|
||||||
|
cargo test --all-features
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
cargo llvm-cov
|
@ -3,8 +3,5 @@ use deadpool_diesel::postgres::BuildError;
|
|||||||
use lib::diesel::pool::PgPool;
|
use lib::diesel::pool::PgPool;
|
||||||
|
|
||||||
pub(crate) fn create_pool() -> Result<PgPool, BuildError> {
|
pub(crate) fn create_pool() -> Result<PgPool, BuildError> {
|
||||||
lib::diesel::pool::create_pool()
|
lib::diesel::pool::create_pool_from_url_with_size(config::DATABASE_URL, config::POOL_SIZE)
|
||||||
.url(config::DATABASE_URL)
|
|
||||||
.size(config::POOL_SIZE)
|
|
||||||
.call()
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user