docs: still WIP

This commit is contained in:
Matthieu Bessat 2026-01-13 21:41:03 +01:00
parent 8f7d11226f
commit d3aae47d2c
7 changed files with 51 additions and 23 deletions

View file

@ -1,8 +1,12 @@
# [WIP] sqlxgentools
Tools to generate SQL migrations and Rust SQLx repositories code from models structs to use with a SQLite database.
Little tool to generate SQLite migrations files and Rust SQLx repositories code, all from models structs.
Will be used in [minauthator](https://forge.lefuturiste.fr/mbess/minauthator).
Still very much work in progress, but it can be already used in your next Rust app if you don't mind some limitations like the lack of incremental migrations and little quirks here and there.
## Getting started
- [Quick start tutorial](./docs/tutorials/quick_start.md)
## Project context
@ -18,10 +22,19 @@ Will be used in [minauthator](https://forge.lefuturiste.fr/mbess/minauthator).
- Provide a full a ORM interface
## Included crates
This project is split into 3 published crates.
- [`sqlxgentools_cli`](https://crates.io/crates/sqlxgentools_cli), used to parse, generate migrations and repositories.
- [`sqlxgentools_attrs`](https://crates.io/crates/sqlxgentools_attrs), provides proc macros.
- [`sqlxgentools_misc`](https://crates.io/crates/sqlxgentools_misc), provides data types and traits (optional).
## Features
- [x] generate migrations
- [x] from scratch
- [ ] incremental migration
- [ ] up migration
- [ ] down migration
- [x] generate repositories
@ -29,27 +42,10 @@ Will be used in [minauthator](https://forge.lefuturiste.fr/mbess/minauthator).
- [x] get_by_id
- [x] insert
- [x] insert_many
- [ ] generate custom by
- [x] co-exist with custom repository
- [x] custom get_by, get_many_by
- [x] get_many_of (from one-to-many relations)
## Usage
## Contributions
### Generate initial CREATE TABLE sqlite migration
Questions, remarks and contributions is very much welcomed.
cargo run --bin sqlx-generator -- ./path/to/project generate-create-migrations > migrations/all.sql
sqlx-generator \
-m path/to/models \
gen-repositories \
-o path/to/repositories
sqlx-generator \
-m path/to/models \
gen-migrations \
-o path/to/migrations/all.sql
### Generate repositories code
not implemented yet
cargo run --bin sqlx-generator -- ./path/to/project generate-repositories

View file

View file

0
docs/references/cli.md Normal file
View file

View file

View file

@ -6,3 +6,34 @@ Steps:
- Generate migrations
- Generate repositories
- Use repositories in your code
### CLI installation
The [sqlxgentools_cli crate](https://crates.io/crates/sqlxgentools_cli) provides the CLI,
it can be installed globally on your machine (or at least your user).
cargo install sqlxgentools_cli
### Project installation
Install the `sqlxgentools_attrs` crate
### Declare your models
TODO
### Generate migrations
Change directory into your project root.
sqlx-generator -m path/to/models_module gen-migrations -o path/to/migrations/all.sql
### Generate repositories
Change directory into your project root.
sqlx-generator -m path/to/models_module gen-repositories -o path/to/repositories_module
### Use the repositories
TODO

View file

@ -0,0 +1 @@
TODO