How to rollback an insert refactoring?

Greetings,

This is a simple question. I’m still beginner in Liquibase anyway.

I have a change set as follows:


  1.         إدخال المشرف الأولي       
           
               
               
                <column name=“Password” valueNumeric=“0x14b6625ab0d924114381d789a7656ce7b3dbd8”  type="${types.password}">
               
               
               
               
               
               
               
               
               
           
       
It works well. But when I roll it back, I get an error. A liquibase.exception.RollbackImpossibleException is thrown

I even don’t know why Liquibase complains? I don’t want to rollback this action as I drop the whole table on the rollback of a previous action.

I tried by every means I can to add rollback instructions, and searched the internet, but all in vain.

How can I solve this? As this problem prevents my whole rollback commands.

Regards,

tags do not have auto-rollback support because liquibase cannot know how to uniquely identify the column to delete.


You can use the tag inside the to specify how to rollback the changeset, however. If you are dropping the whole table in previous rollback and so don’t care if this changeSet is not completely rolled back, you can use an empty rollback tag.


Otherwise, you can specify something like delete from Employee where Code=1 and Name = ‘مشرف’


Nathan

I don’t know why I were logged off. The above post is mine.

That should have worked. What if you try putting some SQL like “delete from Employee where code=1” in the rollback tag?

You are using 2.0.3?


Nathan

Greetings,

I tried all these before. You’ve already mentioned this in the documentation.
What makes me angry is that I saw other people posting on forums doing the same thing and it works for them.

It seems that Liquibase rolls back the set in spite of the error, but doesn’t continue to rollback the other sets.

Here’s the output of my rollback command:

  1. INFO 27/01/12 07:54 ╒:liquibase: Successfully acquired change log lock
    INFO 27/01/12 07:54 ╒:liquibase: Reading from [dbo].[DATABASECHANGELOG]
    INFO 27/01/12 07:54 ╒:liquibase: Rolling Back Changeset:v000/tables/transactions
    Serial.xml::8::ashraf::(Checksum: 3:8cc76e1659987a39ef7eb7492dfe146d)
    INFO 27/01/12 07:54 ╒:liquibase: Rolling Back Changeset:v000/tables/employee.xml
    ::7::ashraf::(Checksum: 3:52f2655840982b712d5289dc9c1fb3a9)
    INFO 27/01/12 07:54 ╒:liquibase: Rolling Back Changeset:v000/tables/employee.xml
    ::6::ashraf::(Checksum: 3:0ee689ab8df7ec31359cdcc512f0c941)
    INFO 27/01/12 07:54 ╒:liquibase: Rolling Back Changeset:v000/tables/group.xml::5
    ::ashraf::(Checksum: 3:49b355bdd7428a53d0d38964e94ee52b)
    INFO 27/01/12 07:54 ╒:liquibase: Successfully released change log lock
    Liquibase Update Failed: No inverse to liquibase.change.core.InsertDataChange cr
    eated
    SEVERE 27/01/12 07:54 ╒:liquibase: No inverse to liquibase.change.core.InsertDat
    aChange created
    liquibase.exception.RollbackFailedException: liquibase.exception.RollbackImpossi
    bleException: No inverse to liquibase.change.core.InsertDataChange created
            at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:401)
            at liquibase.changelog.visitor.RollbackVisitor.visit(RollbackVisitor.jav
    a:23)
            at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
            at liquibase.Liquibase.rollback(Liquibase.java:250)
            at liquibase.integration.commandline.Main.doMigration(Main.java:805)
            at liquibase.integration.commandline.Main.main(Main.java:133)
    Caused by: liquibase.exception.RollbackImpossibleException: No inverse to liquib
    ase.change.core.InsertDataChange created
            at liquibase.change.AbstractChange.generateRollbackStatementsFromInverse
    (AbstractChange.java:145)
            at liquibase.change.AbstractChange.generateRollbackStatements(AbstractCh
    ange.java:115)
            at liquibase.database.AbstractDatabase.executeRollbackStatements(Abstrac
    tDatabase.java:1090)
            at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:388)
            … 5 more


    For more information, use the --logLevel flag)
    Press any key to continue . . .

After this, if run update.bat I get the following output:

  1. INFO 27/01/12 07:55 ╒:liquibase: Successfully acquired change log lock
    INFO 27/01/12 07:55 ╒:liquibase: Reading from [dbo].[DATABASECHANGELOG]
    INFO 27/01/12 07:55 ╒:liquibase: Reading from [dbo].[DATABASECHANGELOG]
    INFO 27/01/12 07:55 ╒:liquibase: ChangeSet v000/tables/employee.xml::6::ashraf r
    an successfully in 47ms
    INFO 27/01/12 07:55 ╒:liquibase: ChangeSet v000/tables/employee.xml::7::ashraf r
    an successfully in 62ms
    INFO 27/01/12 07:55 ╒:liquibase: ChangeSet v000/tables/transactionsSerial.xml::8
    ::ashraf ran successfully in 78ms
    INFO 27/01/12 07:55 ╒:liquibase: Successfully released change log lock
    Liquibase Update Successful
    Press any key to continue . . .

It executes set 6 and 7, which means that they were rolled back in the previous action.

I attach my whole project so you can examine it.

Yes, I use version 2.0.3

Last note: Everything was working very well before adding the insert refactoring

Greetings,

Thanks for your reply,

I’ve tried all these before I came here. And all were in vain.

My setup is imitating your tutorial using Oracle on your website. I have an update.xml and a v000 folder, inside it a master.xml file as follows:


  1.    
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
  2. Liquibase Update Failed: No inverse to liquibase.change.core.InsertDataChange cr
    eated
    SEVERE 26/01/12 08:06 ع:liquibase: No inverse to liquibase.change.core.InsertDat
    aChange created
    liquibase.exception.RollbackFailedException: liquibase.exception.RollbackImpossi
    bleException: No inverse to liquibase.change.core.InsertDataChange created
            at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:401)
            at liquibase.changelog.visitor.RollbackVisitor.visit(RollbackVisitor.jav
    a:23)
            at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
            at liquibase.Liquibase.rollback(Liquibase.java:250)
            at liquibase.integration.commandline.Main.doMigration(Main.java:805)
            at liquibase.integration.commandline.Main.main(Main.java:133)
    Caused by: liquibase.exception.RollbackImpossibleException: No inverse to liquib
    ase.change.core.InsertDataChange created
            at liquibase.change.AbstractChange.generateRollbackStatementsFromInverse
    (AbstractChange.java:145)
            at liquibase.change.AbstractChange.generateRollbackStatements(AbstractCh
    ange.java:115)
            at liquibase.database.AbstractDatabase.executeRollbackStatements(Abstrac
    tDatabase.java:1090)
            at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:388)
            … 5 more

I’m terribly sorry about this.

It turned out that it’s my fault. The error (as it’s obvious in the error message) is at the group.xml file which has an insert operation without a roll back.

Sorry for the disturbance and thanks for your help.

Hope you view my other issue here

Aside from this, I knew you are trying to port LB to .Net
Did you try J#? Did you know about this project: Sharpen?

I’m sorry from posting this here, but the forum didn’t allow me to send a private message

Glad you figured out yoru issue.


I looked at J# a bit, but wasn’t sure on the long-term viability of J# or how much conversion would be required for standard java libraries like JDBC.


I haven’t seen Sharpen before, it may be worth looking into, but it would be nice to keep a consistent codebase between the two if possible. It is enough to manage one codebase, adding a second independent one would make it even harder to keep up :slight_smile: Definitely an option, though. I’m working through some structural refactorings for the next liquibase version. After that is done, I may look into the .net port again. It is lower priority for me at the moment, however. Anyone else is more than welcome to take it and run, however.

Nathan 

Why couldn’t liquibase just delete by using each column in where clause.  For example






Then system would generate delete from t1 where c1=‘v1’ and c2='v2’

99% of the time this would be effectie