How do I create a new entity SQL schema?
Naming conventions and idempotency rules are in SQL entity schema patterns. The codegen-add-sql-schema skill drives this process; codegen is mandatory.
Question
How do I create the SQL schema for a new entity in ORE Studio?
Answer
- Create a JSON model under
projects/ores.codegen/models/{component}/using*_domain_entity.json(UUID PK) or*_junction.json(composite text PK) naming. - Generate the SQL schema file (written directly to
projects/ores.sql/):
./compass.sh codegen entity generate <entity> --profile sql
- Register the new schema file in the orchestration script for the component
(typically
projects/ores.sql/scripts/{component}_schema.sh). - Add RLS policies for the new entity. Every entity table with
tenant_idneeds a tenant isolation policy; tables that also haveparty_idneed a party isolation policy on top. Add them toprojects/ores.sql/create/{component}/{component}_rls_policies_create.sql(create the file if the component has none) and register it inprojects/ores.sql/create/rls/rls_create.sql. See SQL entity schema patterns §Row-Level Security for the exact policy templates. - Run schema validation:
./projects/ores.sql/utility/validate_schemas.sh
- Raise a PR with title
[sql] Add {entity} schema.
Tested by
./projects/ores.sql/utility/validate_schemas.sh — verifies
idempotency and naming conventions for all schema files.
See also
- SQL entity schema patterns — naming conventions and idempotency rules.
- codegen-add-sql-schema — skill that drives this workflow.
- Entity lifecycle — layer ordering overview.