Skip to content

Simplify template component handling to use migrations instead of schema placement#4932

Merged
SaxonF merged 1 commit intopoc/supabase-addfrom
claude/simplify-add-command-M5mdb
Mar 5, 2026
Merged

Simplify template component handling to use migrations instead of schema placement#4932
SaxonF merged 1 commit intopoc/supabase-addfrom
claude/simplify-add-command-M5mdb

Conversation

@SaxonF
Copy link
Copy Markdown

@SaxonF SaxonF commented Mar 5, 2026

Summary

This PR refactors the template component system to simplify SQL handling by removing the complex schema placement logic and consolidating all SQL components into a single "migration" component type. This eliminates hundreds of lines of SQL parsing and merging code while providing a clearer, more predictable behavior for template authors.

Key Changes

  • Removed SQL merging logic: Deleted ~750 lines of complex SQL statement parsing, merging, and deduplication code that attempted to intelligently merge ALTER statements into CREATE statements. This logic was error-prone and difficult to maintain.

  • Unified component types: Replaced multiple schema-based component types (tables, functions, triggers, policies, extensions, etc.) with a single explicit migration component type. Unknown component types now return an error instead of falling back to SQL handling.

  • Simplified migration file creation: Migration files are now created directly in the migrations directory with timestamp-based naming (YYYYMMDDHHMMSS_name.sql) rather than being distributed across schema directories based on component type and schema placement configuration.

  • Removed schema placement configuration: Eliminated the schema_placement configuration system and related code that allowed customizing where different SQL component types were stored. All migrations now go to a single migrations directory.

  • Removed schema_paths configuration: Deleted the logic that automatically added schema_paths to the config when SQL components were added. Migrations are now the primary way to manage database schema changes.

  • Deterministic migration timestamps: Added a migrationTimestamp function that accepts a sequence counter to ensure unique timestamps when multiple migrations are added in a single operation, preventing filename collisions.

Implementation Details

  • The executeMigrationComponent function replaces the previous executeSQLComponent function with a much simpler implementation that directly writes SQL content to a timestamped migration file.

  • Removed dependencies on multigres parser and custom SQL parsing utilities that were used for statement analysis.

  • Updated tests to reflect the new behavior: migrations are created with timestamp prefixes in the migrations directory, and unsupported component types now properly return errors instead of silently falling back to SQL handling.

  • The runtimeState struct now tracks migrationSeq (sequence counter) instead of addedSql (list of added files).

https://claude.ai/code/session_0161GS2RCbLFW2XqrwtjRYfp

Replace the complex SQL merge/parse/placement logic with a simple migration
component type. Templates now use "migration" components that copy SQL files
to the migrations directory with a timestamp prefix. This removes ~1000 lines
of SQL AST parsing, statement merging, and schema placement code.

https://claude.ai/code/session_0161GS2RCbLFW2XqrwtjRYfp
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • develop

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: d47881b3-717d-4946-ad12-1d9aed6300c3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SaxonF SaxonF marked this pull request as ready for review March 5, 2026 00:53
@SaxonF SaxonF requested a review from a team as a code owner March 5, 2026 00:53
@SaxonF SaxonF merged commit a4caee9 into poc/supabase-add Mar 5, 2026
6 of 9 checks passed
@SaxonF SaxonF deleted the claude/simplify-add-command-M5mdb branch March 5, 2026 00:54
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