| Crates.io | kohori |
| lib.rs | kohori |
| version | 0.1.0 |
| 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 |
| size | 147,846 |
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.