Skip to content

Fix/custom statement dependencies - #826

Merged
zachdaniel merged 4 commits into
ash-project:mainfrom
Alt-iOS:fix/custom-statement-dependencies
Aug 20, 2026
Merged

Fix/custom statement dependencies#826
zachdaniel merged 4 commits into
ash-project:mainfrom
Alt-iOS:fix/custom-statement-dependencies

Conversation

@Alt-iOS

@Alt-iOS Alt-iOS commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

This adds a custom_statement ordering for same resource custom statements (ie, a function before its trigger), makes after_tables mean only the table structure and renames after_tables to after_resources to better reflect that it means after the table and custom statements. Addresses #823

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@zachdaniel

Copy link
Copy Markdown
Contributor

For ordering within statements, I think we could simply use the order that they appear in the resource. For after_resource, I think that is a confusingly named thing because multiple resources can share the same table. I'm still not fully convinced that we need it if after_tables is repurposed to just "after the table structure".

@Alt-iOS

Alt-iOS commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

For the after_statements part, let me see if I can make it deterministic. The migration generator stopped preserving declaration order once one of the custom_statements had an after_tables dependency. I’ll see if I can preserve declaration order correctly in that case, which should remove the need for after_statements.

As for after_resource, the name is certainly a choice. I only suggested keeping the old behavior under another name because it was explicitly created for that purpose in the pr that added it. But it's only been in version 2.12.0 so I doubt many are using it, so f you don’t think that behavior needs to remain supported, I’ll remove it and clean up the old facts, comments, and tests in the next commit.

@Alt-iOS

Alt-iOS commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@zachdaniel Pushed deleting the after_statements and after_resource, now this

custom_statements do
  statement :create_function do
    after_tables ["audit_entries"]
    up "CREATE FUNCTION ..."
    down "DROP FUNCTION ..."
  end

  statement :create_trigger do
    up "CREATE TRIGGER ... EXECUTE FUNCTION ..."
    down "DROP TRIGGER ..."
  end
end

Creates this migration order

create widgets table structure
create audit_entries table structure
create function
create trigger

@zachdaniel
zachdaniel merged commit 565c041 into ash-project:main Aug 20, 2026
126 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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