Crates.io | kohori |
lib.rs | kohori |
version | |
source | src |
created_at | 2025-04-22 12:36:56.459483+00 |
updated_at | 2025-04-22 12:36:56.459483+00 |
description | A Rust-based schema model for database migrations with RLS support |
homepage | |
repository | https://github.com/kohori-team/kohori |
max_upload_size | |
id | 1643965 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A Rust-based schema modeling library that generates database migrations, inspired by Drizzle ORM. Kohori provides first-class support for PostgreSQL Row-Level Security (RLS) policies.
use kohori::schema::{Table, Column, DataType};
use kohori::rls::{Policy, PolicyTarget, SecurityContext};
// Define a table with RLS policies
let users = Table::new("users")
.column(Column::new("id", DataType::UUID).primary_key().default("gen_random_uuid()"))
.column(Column::new("username", DataType::Text).not_null().unique())
.column(Column::new("email", DataType::Text).not_null())
.column(Column::new("created_at", DataType::Timestamp).not_null().default("now()"))
.rls_policy(
Policy::new("users_select_policy")
.using("auth.uid() = id")
.target(PolicyTarget::Select)
.security_context(SecurityContext::Authenticated)
);
// Generate migration SQL
let migration = schema.generate_migration("create_users_table");
println!("{}", migration.sql());
Add Kohori to your Cargo.toml:
[dependencies]
kohori = "0.1.0"
For more detailed documentation, see the API documentation.
This project is licensed under the MIT License - see the LICENSE file for details.