Skip to content

feat: add metaschema_public.enum table schema#46

Open
pyramation wants to merge 2 commits intomainfrom
devin/1773552050-metaschema-enum-table
Open

feat: add metaschema_public.enum table schema#46
pyramation wants to merge 2 commits intomainfrom
devin/1773552050-metaschema-enum-table

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Mar 15, 2026

feat: add metaschema_public.enum table schema

Summary

Adds a new metaschema_public.enum table to track PostgreSQL ENUM types in the metaschema. This is the upstream schema definition that corresponds to the triggers and compilation logic merged in constructive-db#581.

Table columns: id (uuid PK), database_id (FK → database), schema_id (FK → schema), name, values text[], plus standard metadata (label, description, smart_tags, category, module, scope, tags).

Constraints: UNIQUE(schema_id, name), cascade deletes from parent database/schema.

Files added/modified:

  • deploy/schemas/metaschema_public/tables/enum/table.sql — CREATE TABLE
  • revert/.../table.sql — DROP TABLE
  • verify/.../table.sql — verify_table call
  • pgpm.plan — new entry with dependencies on schema, database, schema table, and object_category type
  • sql/metaschema-schema--0.15.5.sql — appended compiled SQL

Updates since last revision

  • Updated metaschema-modules snapshot: constraintCount changed from 100951104821 in the "foreign key relationships" test, reflecting the additional FK constraints (db_fkey, schema_fkey) and unique constraint introduced by the new enum table.

Review & Testing Checklist for Human

  • Verify the other constraintCount snapshot (69984) doesn't also need updating. Only the 100951 → 104821 snapshot was reported as failing and updated. The 69984 snapshot ("database_id foreign keys" test) may also be affected — run pnpm test in packages/metaschema-modules to confirm.
  • Verify values as a column name works in all contexts. values is a SQL reserved word. PostgreSQL allows it as a column name, but verify it doesn't cause issues with PL/pgSQL triggers (in constructive-db#581) that reference NEW.values / OLD.values.
  • Verify compiled SQL consistency with deploy file. The compiled SQL was manually synced — check for formatting drift (e.g. uuid_generate_v4 () vs uuid_generate_v4(), E'@omit' vs '@omit').
  • Test deploy/revert cycle against a live database. Run pgpm deploy and pgpm revert to confirm the migration applies and rolls back cleanly.

Notes

  • Requested by: @pyramation
  • Link to Devin Session
  • The upstream compiled SQL (metaschema-schema--0.15.5.sql) appears to be missing some tables that exist in the pgpm.plan (e.g. view, view_table, view_grant, view_rule, default_privilege). This is a pre-existing gap, not introduced by this PR.

- Add enum table with id, database_id, schema_id, name, values text[], plus standard metadata columns
- FKs to database and schema tables, UNIQUE(schema_id, name)
- Indexes on schema_id and database_id
- Deploy/revert/verify migration files
- Update pgpm.plan and compiled SQL
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant