What problem does it solve?
This Skill provides advanced Ecto schema patterns to define robust data structures for complex Elixir applications, covering intricate field types, associations, and schema metadata. It automates the application of sophisticated data modeling techniques.
Core Features & Use Cases
- Flexible Field Types: Utilize
:map and {:array, :type} for unstructured or list data, and virtual fields for computed or temporary values.
- Advanced Associations: Implement
many_to_many with join tables or dedicated join schemas, and self-referencing associations for hierarchical data.
- Custom Primary Keys & Prefixes: Define custom primary keys (e.g., UUIDs, composite keys) and use schema prefixes for multi-tenant applications.
- Use Case: You're building an e-commerce platform where products can have multiple tags and users can belong to multiple organizations with specific roles. Use this Skill to define a
many_to_many relationship between Product and Tag, and a many_to_many with a join schema for User and Organization to store the user's role within each organization, ensuring a flexible and accurate data model.
Quick Start
Use the ecto-schema-patterns skill to define a Product schema with a custom primary key sku of type :string.