How do I create a new entity SQL schema?
Table of Contents
Naming conventions and idempotency rules are in SQL entity schema patterns. The compass-codegen-add-sql-schema skill drives this process; codegen is mandatory.
1. Question
How do I create the SQL schema for a new entity in ORE Studio?
2. Answer
- Confirm the org model under
projects/ores.<component>/modeling/carries#+type: ores.codegen.entity(UUID PK) orores.codegen.junction(composite text PK). Scaffold it withcompass add entity_orgif it does not exist yet. - Generate the SQL schema file (written directly to
projects/ores.sql/):
./compass.sh codegen entity generate <entity> --address ores.sql.schema
- 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.
3. Tested by
./projects/ores.sql/utility/validate_schemas.sh — verifies
idempotency and naming conventions for all schema files.
4. See also
- SQL entity schema patterns — naming conventions and idempotency rules.
- compass-codegen-add-sql-schema — skill that drives this workflow.
- Entity lifecycle — layer ordering overview.