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
Sqitch revert fails to revert to correct change when using tags #312
Comments
Please paste the contents of your |
Hi, Thanks for the fast reply. I will try to reproduce the Problem with a minimal example as I cannot paste the original file here. |
Hello again, here is what I did: idmdev@vagrant-ubuntu-trusty-64:~$ cd sqitchbug/
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ ll
insgesamt 16
drwxrwxr-x 2 idmdev idmdev 4096 Aug 19 15:40 ./
drwxr-xr-x 35 idmdev idmdev 4096 Aug 19 15:40 ../
-rw-rw-r-- 1 idmdev idmdev 426 Aug 19 15:40 sqitch.conf
-rw-rw-r-- 1 idmdev idmdev 42 Aug 19 15:38 sqitch.plan
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch add A
Created deploy/A.sql
Created revert/A.sql
Created verify/A.sql
Added "A" to sqitch.plan
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch tag 1.0
Tagged "A" with @1.0 in sqitch.plan
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch rework A
Added "A [A@1.0]" to sqitch.plan.
Modify these files as appropriate:
* deploy/A.sql
* revert/A.sql
* verify/A.sql
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch deploy
Adding registry tables to sqitchbug
Deploying changes to sqitchbug
+ A @1.0 .. ok
+ A ....... ERROR: duplicate key value violates unique constraint "changes_project_script_hash_key"
DETAIL: Key (project, script_hash)=(sqitchbug, 0376fb90ee0ee8c45a6412db3c91fe7b3dc049dc) already exists.
not ok
Reverting all changes
- A @1.0 .. ok
Deploy failed
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch deploy
Deploying changes to sqitchbug
+ A @1.0 .. ok
+ A ....... ok
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch add B
Created deploy/B.sql
Created revert/B.sql
Created verify/B.sql
Added "B" to sqitch.plan
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch revert A
Revert changes to A @1.0 from sqitchbug? [Yes]
- A .. ok
idmdev@vagrant-ubuntu-trusty-64:~/sqitchbug$ sqitch status
# On database sqitchbug
# Project: sqitchbug
# Change: 46218a8e416f8ec4b802f2685aaf8402350df3c3
# Name: A
# Tag: @1.0
# Deployed: 2016-08-19 15:43:28 +0200
# By: Idm Entwickler,,, <idmdev@vagrant-ubuntu-trusty-64>
#
Undeployed changes:
* A
* B It even says now, that it wants to revert to A@1.0 which is wrong in my opinion, isn't it? I uploaded the resulting sqitch.plan: sqitch.plan.txt By the way, the hashing algorithm failed when trying to add a non modified reworked change which is identical to the original one - is that intended? |
Yep, that's a bug, thank you.
Yes. As part of this plan, the hash on the deploy script must be unique so that Sqitch can use it to do deployment merging. |
Okay, I have a change all ready to commit that fixes this, but then I'm left to wonder. Shouldn't it be that if I say |
I've pushed the change to make it work as described in this ticket in 806d633, but I've also posted a query to the mail list soliciting feedback on this change. Actually curious what most people would expect? I'm leaning towards reverting, personally, because if you really mean the most recent version, you can use the In any event, one way or another, this ticket is resolved. I'll update with the consensus when it's reached. |
Alternate fix to #312. Applies to `revert` and `verify`. When a change is specified by name only and the change appears in the database more than once (becuase it has been reworked), instead of picking the first or last instance (as was done in 806d633), raise an error, instead. When doing so, emit a message telling the user that the change was ambiguous, and list all the alternates with proper tag-qualification. This is done in change_id_for(), which is now documented to rais an error on ambiguous changes. The emitted name and tag are looked up in the database via the existing `name_for_change_id` engine method. It looks like this method wasn't actually being used anywhere, so also modify it to append `@HEAD` when appropriate. Naturally, revert most of the work that went into 806d633a. Also fix a bug in `revert` where it returned an error for duplicate change names in the plan when it found nothing in the database. Done by changing `$plan->get` to `$plan->find`.
I have one tag
version1
and reworked a changex
after it, as rework is only possible when having tags. Later I added another changey
which I wanted to revert and modify whilst testing.But when I issue
sqitch revert x
, sqitch reverts to the change prior toversion1
which i consider to be a major critical bug when it would occur in my live db and not in testing. Am I missing something or needs this to be fixed? I tested it in the latest public version 0.9995.Best regards,
Christian
The text was updated successfully, but these errors were encountered: