sbdchd / squawk

🐘 linter for PostgreSQL, focused on migrations
https://squawkhq.com
GNU General Public License v3.0
594 stars 40 forks source link

Search for specified delimeter to split transactions #317

Open kudrevatykh opened 1 year ago

kudrevatykh commented 1 year ago

We use liquibase formatted sql format for our migrations https://docs.liquibase.com/concepts/changelogs/sql-format.html Problem occurs when we use several changes in single sql file. squawk considers that all changes in file are run in single transaction becase we use --assume-in-transaction flag. It would be nice if squawk split migration file in several transactions by user-specified delimeter (in our case if line starts with --changeset it means that different transaction starts). Now we mandated to write each migration in separate file.

sbdchd commented 1 year ago

One tricky thing is the Postgres parser doesn't return AST nodes for comments so we'd have to bolt something on top for that

kudrevatykh commented 1 year ago

I think such splitting could be made before Postgres parser.