Apply linter only on migrations after specific version
I'd like to exclude old .sql files from the linter check to integrate it in our pipeline. The reason being that I want to fail the build if squawk complains, but I don't want to touch the older migration files since the system is in production atm. Is there any way to do this atm or does it require a new feature implementation?
fwiw, the migrations folder looks like this (which I believe it is pretty standard):
./migrations/
/0001_main_table.up.sql
/0001_main_table.down.sql
/0002_new_table.up.sql
/0002_new_table.up.sql
/0003_add_param_new_table.up.sql
/0003_add_param_new_table.down.sql
And I'd like to have a catch all command that would only check the migrations after a certain version, e.g. $ squawk ./migrations ---from-version 2, which would lint the migration files 0002_* and 0003_* only.
This could also be accomplished by adding a degree of indirection by calling a bash script that calls squawk explicitly for each file in the migrations folder after a certain version. However, I think this would be a neat feature to include natively.
Yeah in the past I've used some wrapper scripts to specify only the files that have changed (using some git diff stuff):
https://github.com/chdsbd/kodiak/blob/533e5faa3ac259c5b53f81a3295fe8897105becc/web_api/s/squawk.py#L146-L150
I'm curious what the equivalent bash/python script would look like for the case you've outlined aka how much we'd save by adding the feature
I'm using an one liner for that:
$ squawk $(find ./migrations/ -name 002[5-9]* && find ./migrations/ -name 00[3-9]*)
which basically picks up all files from ./migrations/0025*.sql and upwards to 009*.sql