Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply linter only on migrations after specific version #191

Open
gpestana opened this issue Mar 25, 2022 · 2 comments
Open

Apply linter only on migrations after specific version #191

gpestana opened this issue Mar 25, 2022 · 2 comments

Comments

@gpestana
Copy link

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.

@sbdchd
Copy link
Owner

sbdchd commented Mar 25, 2022

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

@gpestana
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants