ecto-schemas

Implement Ecto schemas with fields, associations, embeds, and changesets in Elixir.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill ecto-schemas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ecto-schemas
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-ecto/skills/ecto-schemas
Command: npx skills add https://github.com/TheBushidoCollective/han --skill ecto-schemas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you effectively model your database entities in Elixir applications using Ecto schemas, defining field types, associations, and embedded schemas for robust data structures. It automates the process of database schema definition.

Core Features & Use Cases

  • Basic Schema Definition: Define database table structures with fields, types (string, integer, decimal, boolean, datetime, enum, map, array, binary), and timestamps().
  • Associations: Model relationships like belongs_to, has_many, has_one, and many_to_many to connect your data entities.
  • Embedded Schemas: Store nested JSON-like data directly within a parent schema, simplifying complex data structures without extra tables.
  • Use Case: You're building a blog platform and need to define Post, Comment, and User entities. Use this Skill to quickly set up their schemas, define Post has_many Comments, Comment belongs_to Post, and embed an Address schema directly into the User for billing information, ensuring data integrity and clear relationships.

Quick Start

Use the ecto-schemas skill to define an Ecto schema for a Product with fields for name (string), price (decimal), and quantity (integer).

Frequently Asked Questions about ecto-schemas

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define database entities and relationships in Elixir applications?

Ecto schemas model database entities by declaring fields with types (string, integer, decimal, boolean, datetime, enum, map, array), associations (belongs_to, has_many, has_one, many_to_many), and timestamps. Schemas provide the structure and validation pipeline for your data.

What's the best way to handle nested data structures in Elixir without creating extra database tables?

Embedded schemas store nested JSON-like data directly within a parent schema using embeds_one and embeds_many, eliminating the need for separate tables while maintaining data integrity and clear hierarchical relationships.

How do I set up associations between multiple database entities in Ecto?

Ecto associations (belongs_to, has_many, has_one, many_to_many) connect data entities by defining foreign key relationships and cardinality. These relationships enable querying across related records and maintaining referential integrity.

Can I validate and transform data before saving it to the database in Ecto?

Changesets provide a validation and transformation pipeline including casts, validations, constraints, and unique constraints. This ensures data integrity and enforces business rules before persisting to the database.

What field types does Ecto support for modeling different kinds of data?

Ecto supports basic types (string, integer, boolean, decimal, float), complex types (arrays, maps, custom Ecto.Enum), date/time fields, binary data, and virtual fields for computed values not stored in the database.

Do I need custom types to handle specialized data in Ecto schemas?

Ecto's built-in types cover most use cases including basic scalars, collections, and temporal data. Custom types extend this when you need domain-specific serialization or validation logic beyond standard field definitions.