cleanup minor things

This commit is contained in:
2021-08-20 15:05:50 -05:00
parent 4b859492c1
commit 01d2afb3dd
9 changed files with 41 additions and 19 deletions

View File

@@ -12,9 +12,11 @@ log = { version = "^0.4", features = [
] }
fern = "^0.5"
# serialization
serde = { version = "^1.0.127", features = ["derive"] }
serde_json = "^1.0.66"
# ids
uuid = { version = "0.8.2", features = ["v4"] }
# sqlx

View File

@@ -5,7 +5,7 @@ all:
clean:
rm -rf target
rm -rf test.db*
rm -rf demo.db*
build:
cargo build
@@ -15,7 +15,7 @@ test:
up:
docker-compose up -d
rm -rf test.db*
rm -rf demo.db*
down:
docker-compose down

View File

@@ -1 +1,21 @@
# sqlx Test
# `sqlx` Test
This is a test program to try few things with the `sqlx` library.
The idea is to figure out everything needed to support
moving [cqrs-es2](https://github.com/brgirgis/cqrs-es2) to use `sqlx`.
## Build
To build the executable simply trigger `Cargo`
cargo build
## Usage
To run the executable you will need to spin up the database stack:
docker-compose up -d
Wait for a few seconds for the stack to be ready and then you can run the executable:
cargo run

View File

@@ -8,7 +8,7 @@ services:
networks:
- default
ports:
- "8084:3306"
- "8081:3306"
environment:
#- "MARIADB_USER=root"
- "MARIADB_ROOT_PASSWORD=admin_pass"
@@ -24,7 +24,7 @@ services:
networks:
- default
ports:
- "8085:1433"
- "8082:1433"
environment:
#- "SA_USER=sa"
- "SA_PASSWORD=adm1n_pa%s"
@@ -37,7 +37,7 @@ services:
networks:
- default
ports:
- "8086:3306"
- "8083:3306"
environment:
#- "MYSQL_USER=root"
- "MYSQL_ROOT_PASSWORD=admin_pass"
@@ -50,7 +50,7 @@ services:
networks:
- default
ports:
- "8087:5432"
- "8084:5432"
environment:
- "POSTGRES_USER=admin"
- "POSTGRES_PASSWORD=admin_pass"
@@ -61,7 +61,7 @@ services:
networks:
- default
ports:
- "8083:8080"
- "8080:8080"
depends_on:
- maria-db
- mysql-db

View File

@@ -58,10 +58,10 @@ WHERE
";
pub async fn get_pool() -> Result<MySqlPool, sqlx::Error> {
// "mysql://demo_user:demo_pass@localhost:8084/demo"
// "mysql://demo_user:demo_pass@localhost:8081/demo"
let options = MySqlConnectOptions::new()
.host("localhost")
.port(8084)
.port(8081)
.database("demo")
.username("demo_user")
.password("demo_pass");

View File

@@ -57,10 +57,10 @@ WHERE
";
pub async fn get_pool() -> Result<MssqlPool, sqlx::Error> {
// "mssql://sa:'adm1n_pa%s'@localhost:8085/demo"
// "mssql://sa:'adm1n_pa%s'@localhost:8082/demo"
let options = MssqlConnectOptions::new()
.host("localhost")
.port(8085)
.port(8082)
.database("demo")
.username("demo_user")
.password("pas$w0rd");

View File

@@ -58,10 +58,10 @@ WHERE
";
pub async fn get_pool() -> Result<MySqlPool, sqlx::Error> {
// "mysql://demo_user:demo_pass@localhost:8086/demo"
// "mysql://demo_user:demo_pass@localhost:8083/demo"
let options = MySqlConnectOptions::new()
.host("localhost")
.port(8086)
.port(8083)
.database("demo")
.username("demo_user")
.password("demo_pass");

View File

@@ -48,7 +48,7 @@ UPDATE
events
SET
payload = $1,
metadata = $1
metadata = $2
WHERE
aggregate_type = $3
AND
@@ -58,10 +58,10 @@ WHERE
";
async fn get_pool() -> Result<PgPool, sqlx::Error> {
// "postgres://demo_user:demo_pass@localhost:8087/demo"
// "postgres://demo_user:demo_pass@localhost:8084/demo"
let options = PgConnectOptions::new()
.host("localhost")
.port(8087)
.port(8084)
.database("demo")
.username("demo_user")
.password("demo_pass");

View File

@@ -72,9 +72,9 @@ WHERE
";
pub async fn get_pool() -> Result<SqlitePool, sqlx::Error> {
// "sqlite://test.db"
// "sqlite://demo.db"
let options = SqliteConnectOptions::new()
.filename("test.db")
.filename("demo.db")
.create_if_missing(true);
let pool = SqlitePoolOptions::new()