Skip to content

Conversation

@xardasos
Copy link
Contributor

@xardasos xardasos commented Nov 17, 2025

This PR optimizes views migration. In the case of metadata changes, it is not always necessary to recreate views if the engine doesn't support view comments. This optimization is especially relevant for materialized views, which can take more time to be rebuilt.

@xardasos
Copy link
Contributor Author

xardasos commented Dec 18, 2025

Hi @izeigerman, @erindru and @eakmanrq, I'd appreciate your review of this PR.

The changes aim to prevent unnecessary view (especially MV) recreation when deploying Metadata snapshots to production on engines that don't support view comments. In previous versions of SQLMesh (before 0.183.0, related to #4414), metadata changes didn't trigger view recreation. This PR aims to restore this behavior while still allowing view recreation in scenarios where it's necessary.

Note: For engines that support comments in post-creation commands (like COMMENT or ALTER), we might be able to avoid recreation and only update the comments. This optimization is not included in this PR. However, it's unlikely to be feasible for engines that only allow comments in CREATE VIEW schema definitions.

I'm open to any suggestions you may have. Thanks for your time!

@tobymao tobymao closed this Jan 8, 2026
@xardasos
Copy link
Contributor Author

xardasos commented Jan 9, 2026

Hi @tobymao, I noticed that the PR was closed and I just wanted to ask if there's something I could adjust. I realize now that I should have also mentioned earlier in the PR description that one of my goals is to address a bug that causes data to be unavailable in production for a long time and makes rollback difficult. I've created a related issue (#5653). I'd be happy to update or resubmit if this PR change is useful. Thanks for maintaining this project.

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