A blog system build with rust.
- rust
- axum: A ergonomic and modular web framework
- tracing: Application level tracing for Rust
- sqlx: an async, pure Rust† SQL crate featuring compile-time checked queries without a DSL.
- serde: Serialization framework for Rust
- thiserror: derive(Error) for struct and enum error types
- dotenvy: A well-maintained fork of the Rust dotenv crate
- argon2: Pure Rust implementation of the Argon2 password hashing function
- base64: base64, in rust
- jsonwebtoken: JWT lib in rust
- secrecy: A simple secret-keeping library for Rust.
- Install toolchain
$ cargo install sqlx-cli
- create .env file, like:
# .env
DATABASE_URL=mysql://mysql@localhost/db_name
- create/drop database
sqlx database create # create database
sqlx database drop # drop database
- create and run migrations
create migrate, will create a new file in migrations/<timestamp>-<name>.(up/down).sql
:
sqlx migrate add -r <name>
then add your database scheme to this file
run migrations
sqlx migrate run
more information to read sqlx-cli document