Depot.Schema: typed schema definitions for database tables.
A schema is a plain March value produced by Depot.Schema.define/2. It captures the table name, field types/options, associations, and primary key. Schemas drive Gate v2, Repo, Query, and Migration.
Usage:
fn schema() do
Depot.Schema.define("users", {
fields = {
name = "String",
email = "String",
age = ("Int", { default: 0 }),
role = ("String", { default: "user" })
}
})
end
let s = schema()
Depot.Schema.table(s) -- => "users"
Depot.Schema.field_names(s) -- => ["name", "email", "age", "role"]
Depot.Schema.blank(s) -- => { name: "", email: "", age: 0, role: "user" }