Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 14, 2026

Summary

Adds the table_template_module table and removes the three old module tables it replaces: user_profiles_module, user_settings_module, and organization_settings_module.

The new table_template_module enables unified table creation templates using node_type dispatch, allowing different table types to be created through a single module table rather than requiring separate module tables for each type.

This is an upstream sync from constructive-db PR #340.

Table structure:

  • database_id, schema_id, private_schema_id - standard module references
  • table_id, owner_table_id - references to created table and owner table
  • table_name - name of the table to create
  • node_type - template type for dispatch (e.g., 'TableUserProfiles', 'TableOrganizationSettings', 'TableUserSettings')
  • data - jsonb for type-specific parameters

Review & Testing Checklist for Human

  • Breaking change: Verify downstream consumers are not using the removed modules (user_profiles_module, user_settings_module, organization_settings_module) directly
  • Verify the table structure matches the implementation in constructive-db
  • Verify all foreign key columns have corresponding indexes (database_id, schema_id, private_schema_id, table_id, owner_table_id, node_type)
  • Run pnpm test in packages/metaschema-modules to ensure tests pass

Recommended test plan:

  1. Deploy the migration to a test database with metaschema-schema already installed
  2. Verify the table_template_module table is created with correct structure
  3. Verify the old module tables are properly removed

Updates since last revision

  • Removed old module tables: user_profiles_module, user_settings_module, organization_settings_module
  • Updated test snapshots:
    • moduleTablesCount: 26→24, totalTables: 27→25
    • constraintCount for database_id FK test: 78650→67416
    • constraintCount for FK relationships test: 113921→94299
  • Removed entries from pgpm.plan for deleted modules

Notes

This is a breaking change for any consumers using the old module tables directly. The trigger logic and generator functions that dispatch based on node_type live in constructive-db, not this public repo.

Link to Devin run: https://app.devin.ai/sessions/f4b2066a3e3e434da15de84fba001ac3
Requested by: Dan Lynch (@pyramation)

@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

@devin-ai-integration devin-ai-integration bot changed the title Add table_template_module for unified table creation templates Add table_template_module and remove old settings modules Jan 14, 2026
@pyramation pyramation merged commit 7fae5b6 into main Jan 14, 2026
22 checks passed
@pyramation pyramation deleted the devin/1768372712-table-template-module branch January 14, 2026 07:25
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.

2 participants