Tools to generate SQL migrations and Rust SQLx repositories code from models structs.
Find a file
2026-01-06 00:27:31 +01:00
docs/tutorials feat: one-to-many relation helper 2026-01-04 22:14:00 +01:00
lib WIP 2026-01-06 00:27:31 +01:00
.gitignore initial commit 2024-12-27 23:00:38 +01:00
.rgignore initial commit 2024-12-27 23:00:38 +01:00
Cargo.lock feat: one-to-many relation helper 2026-01-04 22:14:00 +01:00
Cargo.toml feat: one-to-many relation helper 2026-01-04 22:14:00 +01:00
DRAFT.md feat: one-to-many relation helper 2026-01-04 22:14:00 +01:00
LICENSE-APACHE build: workspace packages metadata and license 2025-10-12 15:12:08 +02:00
LICENSE-MIT build: workspace packages metadata and license 2025-10-12 15:12:08 +02:00
README.md test(sandbox): add repository testing 2025-10-12 14:02:20 +02:00
TODO.md feat(repositories): add get_many_by_id method 2025-07-31 17:15:00 +02:00

[WIP] sqlxgentools

Tools to generate SQL migrations and Rust SQLx repositories code from models structs to use with a SQLite database.

Will be used in minauthator.

Project context

Goals

  • Help developers that dont use ORM and use SQLx in a Rust project with a SQLite DB.
  • Auto generate boilerplate repositories pattern code
  • Auto generate CREATE TABLE base migrations from model struct
  • Auto generate Up and Down migrations
  • Let developer have flexibility over the model definition

Non-goals

  • Provide a full a ORM interface

Features

  • generate migrations
    • from scratch
    • up migration
    • down migration
  • generate repositories
    • get_all
    • get_by_id
    • insert
    • insert_many
    • generate custom by
    • co-exist with custom repository

Usage

Generate initial CREATE TABLE sqlite migration

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