Skip to content

Drop tables on missing resources & table name change handling#713

Merged
zachdaniel merged 11 commits intoash-project:mainfrom
obviouslyweb:main
Mar 13, 2026
Merged

Drop tables on missing resources & table name change handling#713
zachdaniel merged 11 commits intoash-project:mainfrom
obviouslyweb:main

Conversation

@obviouslyweb
Copy link
Contributor

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

Attempts to resolve #224 and #256 with regards to the migration generator, notably with table dropping upon resources missing and prompting the user if the generator detects a potential name change intent.

@zachdaniel
Copy link
Contributor

This is definitely a great QOL improvement, but when it comes to generating migrations that can result in such a significant loss of data I hesitate a little bit. I think we should prompt also on table deletion. If they say no, we should record in the snapshot that they opted out and not ask them again in the future.

Thoughts?

@obviouslyweb
Copy link
Contributor Author

I think that makes sense. Given how critical migrations are, you really don't want to make any assumptions about what the user wants. I'll work on implementing that!

@obviouslyweb
Copy link
Contributor Author

I've gone through and implemented a confirmation step for dropping tables as well; feedback/suggestions appreciated!

@zachdaniel
Copy link
Contributor

Please run mix credo and resolve any issues 😄

@obviouslyweb
Copy link
Contributor Author

My apologies about those errors 😅 They should hopefully all be resolved with the new commits!

@zachdaniel
Copy link
Contributor

Looks like code generation required in test:

** (Ash.Error.Framework.PendingCodegen) Pending Code Generation Detected for 1 files

MIX_ENV=test mix ash_postgres.generate_migrations update_test_files

@obviouslyweb
Copy link
Contributor Author

I was pretty stumped for a while since that error didn't originally trigger on my local envoirnment, but I found that the migration generator was defaulting to dropping orphan tables during the check. That's why it kept triggering code generation. The new commit should resolve that; apologies for all the unexpected issues!

@zachdaniel zachdaniel merged commit 63bb540 into ash-project:main Mar 13, 2026
64 of 67 checks passed
@zachdaniel
Copy link
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.

drop tables on resources being missing

2 participants