annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Option skip_on_db_migrate not honored

Open martinechtner opened this issue 3 months ago • 6 comments

Hi, the option skip_on_db_migrate does not seem to be honored when set to true in the yaml options file.

My config:

# .annotaterb.yml

...
:skip_on_db_migrate: true
...

Expected behaviour

When running migrate commands annotations would not be run.

Actual behaviour

Annotations are run.

martinechtner avatar Sep 24 '25 15:09 martinechtner

@drwl when you have a chance could I get a review on this?

martinechtner avatar Oct 06 '25 16:10 martinechtner

@martinechtner I will review it now

drwl avatar Oct 20 '25 01:10 drwl

I looked at the PR and was debugging locally. You are right that the skip_on_db_migrate option is not respected.

Can you share more about your workflow? I would imagine if you want to skip on db migrate then you just delete the rake task.

drwl avatar Oct 20 '25 02:10 drwl

@drwl we have a few steps in our CI process where we need to migrate the extra output of Model files unchanged., etc was causing these steps to fail. I was able to get around the issue by setting ANNOTATERB_SKIP_ON_DB_TASKS=true when calling the migration command.

When deploying we run migrations, at this point there is no need to run annotations so honoring the skip_on_db_migrate is ideal rather than having to set ANNOTATERB_SKIP_ON_DB_TASKS=true.

We also have some CI tasks that check if annotations were run when we have migrations to ensure the correct annotations are present. That said we don't need to always run annotations when we run migrations locally in our dev environments, the additional time needed to check if there are any annotations is unnecessary, so being able to turn it off is desirable via the skip_on_db_migrate option.

martinechtner avatar Oct 20 '25 15:10 martinechtner

Bump!

  • We prefer to run annotations in a pre-commit hook
  • Most db:migrate calls are run after pulling changes from main (not after adding a migration yourself) and in this case running annotations is unnecessary/undesired
  • Devs often have schema drift locally (its own issue) and so undesired annotations often sneak in

tony-pizza avatar Nov 17 '25 18:11 tony-pizza

Deleting the rake task is also fine in our case. Let's remove the skip_on_db_migrate setting if that's the route forward.

tony-pizza avatar Nov 17 '25 18:11 tony-pizza