concourse: Downgrade to 7.4.0 database (1625844436) fails
Summary
When attempting to downgrade the database to 7.4.0 as instructed in the 7.4.3 release notes it fails.
Steps to reproduce
Run concourse migrate --migrate-db-to-version=1625844436 on a 7.4.2 database.
Expected results
The migration should work and allow us to upgrade to 7.4.3.
Actual results
error: could not migrate to version: 1625844436 Reason: migration '1625844437_drop_build_event_id_seq.down.sql' failed and was rolled back: pq: invalid input syntax for type integer: "select max(event_id) from pipeline_build_events_"
Triaging info
- Concourse version: 7.4.2
- Did this used to work? No idea.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (7 by maintainers)
Commits related to this issue
- atc: fix down migration There was a typo in the down migration. It never got properly tested because the downgrade integration tests never actually runs these down migrations since they are only run ... — committed to concourse/concourse by clarafu 3 years ago
- db: modify down migration to loosen requirements Berber31 brought up a good point that there can be builds that have been aborted but not yet completed that still require some build output. Therefore... — committed to concourse/concourse by clarafu 3 years ago
- db: further improve down migration The down migration also does not over pending builds. Previously, we would create build event sequences once we call createBuild and these builds start off with a p... — committed to concourse/concourse by clarafu 2 years ago
@AndoniLarz Thanks so much for the information, that’s actually very useful because that pending build was not fixed by my script. I’ll update the script and the migration with this, thanks!!
Finally got around to running this and it seems to have worked. Thanks again!
@clarafu thank you so much! Script worked as expected, successfully upgraded to 7.4.3 from 7.4.2.
I’ve created a script that contains
And done some manual testing and it seems to work. Basically what this script does is run the down migrations necessary for downgrading from 7.4.1 or 7.4.2 and also removes the history that the up migration that was included in 7.4.1 or 7.4.2. This is a little different from what a proper downgrade does to your database but I needed to do it this way because of a little unfortunate situation (if you want to know more I explain it in more detail here https://github.com/concourse/concourse/issues/7884)
So for users that are currently on 7.4.1 or 7.4.2, if you run the script that I pasted above you will be able to upgrade to 7.4.3, 7.5.0 or 7.6.0. Or if you want you can also downgrade back to 7.4.0 (you will NOT need to run any
concourse migratecommands anymore to downgrade to 7.4.0 if you run the script).The script requires you to have the
psql, access to your postgres database and also the following environment variables that you should already have from starting concourse$CONCOURSE_POSTGRES_PASSWORD,$CONCOURSE_POSTGRES_USER,$CONCOURSE_POSTGRES_HOST,$CONCOURSE_POSTGRES_DATABASE,$CONCOURSE_POSTGRES_PORT.I think I’m going to create a script that you can run against your database that will fix it and then you will be able to downgrade back to 7.4.0!