With DataGrip, I know there's a way to generate SQL scripts based on the database schema (Right click on the table > SQL Scripts
> SQL Generator
). However, is there a way to get DataGrip to automatically update these generated SQL scripts whenever the schema changes via queries (DDL) or the UI (Modify Table
option)?
Right now, if I want my SQL script files to be under version control and if I want these files to reflect the latest state/schema of my database, I have to:
Instead, I want to:
New > Create Table
option or Right click on the table > Modify Table
option.Save
/ Commit
, modify the corresponding SQL scripts in my local repository and create a new commit. This will then trigger my CI/CD pipeline to build, test and deploy my changed schema.P.S: This is similar to what Red-Gate's SQL Source Control
can do in SQL Server Management Studio. Unfortunately, they don't have a plugin for DataGrip.
Now DataGrip cannot automatically update SQL files according to schema changing. We have the idea to implement this in the future. I think the best ticket to upvote will be: https://youtrack.jetbrains.com/issue/DBE-3852
Anyway, your current algorithm seems to be not the most effective. What I would offer: