Blog Schema
A full blog schema demonstrating authentication, content management, and relationships.
User Table
Section titled “User Table”export default table({ id: col.id(), email: col.email().unique(), username: col.username().unique(), password: col.password_hash(), is_active: col.flag(true),}).timestamps();Post Table
Section titled “Post Table”export default table({ id: col.id(), author: col.belongs_to("auth.user"), title: col.title(), slug: col.slug().unique(), body: col.body(), status: col.enum(["draft", "published", "archived"]).default("draft"), published_at: col.datetime().optional(),}) .timestamps() .soft_delete();Comment Table
Section titled “Comment Table”Self-referential replies allow nested comment threads.
export default table({ id: col.id(), post: col.belongs_to("blog.post"), author: col.belongs_to("auth.user"), parent: col.belongs_to("blog.comment").optional(), body: col.text(), is_approved: col.flag(false),}) .timestamps() .soft_delete();Tag Table
Section titled “Tag Table”Many-to-many relationship with posts for flexible categorization.
export default table({ id: col.id(), name: col.name().unique(), slug: col.slug().unique(), posts: col.many_to_many("blog.post"),}).timestamps();