ezidam/crates/database
Philippe Loctaux 1478c516b3 ci: added gitea actions
commit f80f2b021611b77484ace51634df136ef5100c9f
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 18:30:50 2023 +0200

    cargo update

commit 8055f488d9f764a6f19ed33df79c90acc0caa92b
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 18:19:25 2023 +0200

    ci: formatting yml

commit a62e37dd3963981717d182c9cd9bce06f6ac9f3a
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 18:10:49 2023 +0200

    ci: tokei

commit 7c05cc674466a7ae494221d9924e0a84ac1d636f
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 18:00:50 2023 +0200

    fmt

commit a50c26294984e4f7ac3f96a34d544f26fd71d3a7
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:53:04 2023 +0200

    ci: clippy, fmt check

commit 9e09d900efd6d38aa55c28d0aca71c352d240367
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:35:47 2023 +0200

    ci: dont force all features

commit 1a3fc8d26678b15c66cbaffe4b9581f1fc1d2500
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:34:55 2023 +0200

    removed rust-toolchain.toml

commit ca110d611dc4fc7990b23c2db9853d786a2debd3
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:33:24 2023 +0200

    ci: using full github url

commit ab49ae807e3e2cc96ec0ff2351c67f467b5d88ae
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:32:46 2023 +0200

    ci: added rust workflow

commit ce9393451412327d61585862293209f4380eacec
Author: Philippe Loctaux <p@philippeloctaux.com>
Date:   Sun Jul 9 17:18:44 2023 +0200

    ci: initial commit with gitea actionsss
2023-07-09 19:02:23 +02:00
..
migrations permissions: homepage, sql + crate, add/remove/view for user 2023-05-08 17:15:21 +02:00
queries admin dashboard: apps, users, roles, logins in the last 24 hours 2023-05-08 19:43:44 +02:00
src admin dashboard: apps, users, roles, logins in the last 24 hours 2023-05-08 19:43:44 +02:00
build.rs ci: added gitea actions 2023-07-09 19:02:23 +02:00
Cargo.toml added database crate, "settings" with migrations and queries, running migrations on web startup 2023-02-27 16:07:18 +01:00
justfile added database crate, "settings" with migrations and queries, running migrations on web startup 2023-02-27 16:07:18 +01:00
readme.md added database crate, "settings" with migrations and queries, running migrations on web startup 2023-02-27 16:07:18 +01:00
sqlx-data.json admin dashboard: apps, users, roles, logins in the last 24 hours 2023-05-08 19:43:44 +02:00

sql

sql interactions for ezidam

the purpose of this crate is only to interact with the database

initial setup

tools

  • just run to run pending migrations (in case they are not already applied)
  • just reset to trash the database, create a new one and apply migrations

offline

save

the command just offline is used to verify if all sql queries are valid. the result will be placed in sqlx-data.json and is used to compile the crate. if this command fails the crate will not compile.

since this command will have be executed frequently, find a way to run this command when any files are modified inside this crate.

check

the command just offline_check is here to verify if offline data is up-to-date. it will return a nonzero exit status if data is not up-to-date.

it is mainly used in CI, but you can also use it to determinate if just offline is required to run.

migrations

new

use just new <name> to create a new SQL migration. the parameter <name> should indicate what the migration is doing.

fix mistakes

if there is a mistake in the latest migration, but it has already been applied, use just revert_last to revert it. make your modifications, and run just run to apply it again.

note: this works only for the most recent migration, if there is a mistake in an earlier migration, you will have to reset the whole database with just reset.

consider making a new migration to fix the broken migration, and document it.

miscellaneous

the command just build_script will create a rust build script build.rs to trigger recompilation when a new migration is added. this action can be done only at the beginning of the project.