Fix old changes

80 views
Skip to first unread message

Ruslan Fadeev

unread,
Nov 15, 2021, 1:32:10 PM11/15/21
to Sqitch Users
I have a repo with a Sqitch project. Some of the changes fail on an empty database: one expects data that wasn't added in a Sqitch change to exist, another has a `verify` with invalid SQL in it.

I want to fix these old changes so that `sqitch deploy` works on a new database.

There's `sqitch rework`, but I don't understand how exactly it works and what exactly should be idempotent. However the old changes are not idempotent. Does this mean that `sqitch rework` cannot be used?

Sqitch seems to also have some capabilities for applying changes out of order defined in `sqitch.plan`. Can I somehow add a new change with the data necessary for the old change and make Sqitch run the new change first?

Ruslan Fadeev

unread,
Nov 18, 2021, 12:39:02 PM11/18/21
to Sqitch Users
I think I can reformulate my questions as these two:

1. What exactly happens during `sqitch deploy` when a plan contains several changes with the same name and different tags?
2. Is it possible to repair an old change manually, by updating the `sqitch` database? Is there a better way?

Ruslan Fadeev

unread,
Nov 18, 2021, 12:51:36 PM11/18/21
to Sqitch Users
Moving some discussion from https://github.com/sqitchers/sqitch/issues/594: I read the tutorial, and the critical missing part for me was the logic behind the list of changes it suggests as necessary for altering an older change.

I toyed with an empty sqitch project, and it seems to apply both the new and the old change when deployed on an empty database, but starts with the new change. This doesn't match any of the models I had for how `sqitch rework` is supposed to work, so I'm stumped.

I'm trying to read the source now, but would really appreciate it if someone could point me in the right direction.

Ruslan Fadeev

unread,
Dec 10, 2021, 9:37:53 AM12/10/21
to Sqitch Users
I ended up with a workaround: a rollup of the first N migrations that combines a sqitch database of a production instance with a main database generated by fixing and applying old migrations. New database can be generated by taking the snapshot and applying the remaining sqitch migrations on top.

Ruslan Fadeev

unread,
Jan 4, 2022, 11:10:48 AM1/4/22
to Sqitch Users
For posterity, a useful feature that I missed is `sqitch deploy --log-only` that updates the sqitch database without applying migrations.
Reply all
Reply to author
Forward
0 new messages