tlberglund / groovy-liquibase

Yet Another Groovy DSL for Liquibase
Other
85 stars 66 forks source link

Bug : sqlFile change #1

Closed ErwinvanBrandwijk closed 13 years ago

ErwinvanBrandwijk commented 13 years ago

I tried to use sqlFile but I keep getting an error:

    Liquibase Update Failed: Unknown Reason
    SEVERE 3/7/11 4:15 PM:liquibase: Unknown Reason
    java.lang.NullPointerException
at liquibase.change.core.SQLFileChange.loadFromFileSystem(SQLFileChange.java:119)

at liquibase.change.core.SQLFileChange.init(SQLFileChange.java:83)

    For more information, use the --logLevel flag)
at liquibase.changelog.visitor.ValidatingVisitor.visit(ValidatingVisitor.java:72)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:131)
at liquibase.Liquibase.update(Liquibase.java:110)
at liquibase.integration.commandline.Main.doMigration(Main.java:686)
at liquibase.integration.commandline.Main.main(Main.java:115)

This is the changeset: changeSet(author: "erwin", id: "10") { comment("dump")

    sqlFile(path: "dump.sql") 
}

Also tried: changeSet(author: "erwin", id: "10") { comment("dump")

    sqlFile(path: "/home/fook/workspace/Groovy-Liquibase/dump.sql")  
}

And changeSet(author: "erwin", id: "10") { comment("dump")

    sqlFile(path: "~/workspace/Groovy-Liquibase/dump.sql", 
    stripComments: false, splitStatements: true, encoding: "utf8", 
            endDelimiter: ";") 
}

And (editted changeSetDelegate sqlFile I added relativeToChangelogFile) changeSet(author: "erwin", id: "10") { comment("dump")

    sqlFile(path: "dump.sql", relativeToChangelogFile: true,
    stripComments: false, splitStatements: true, encoding: "utf8", 
            endDelimiter: ";") 
}

None of them worked.

tlberglund commented 13 years ago

Should be fixed in SHA: 51f01067431c2135d3b8ce21fa63685992425a6d. I ran the following changelog, and a table was created:

databaseChangeLog() {
  new File('test.sql').withPrintWriter { pw ->
    pw.println "CREATE TABLE monkey (id int, mood varchar(50))"
  }

  changeSet(id:'monkey', author: 'tlberglund') {
    sqlFile(path: 'test.sql')
  }
}
ErwinvanBrandwijk commented 13 years ago

It is working now, great. You should at relativeToChangelogFile.

 void sqlFile(Map params) {
   def change = makeChangeFromMap(SQLFileChange, params, ['path', 'stripComments', 'splitStatements', 'encoding', 'endDelimiter','relativeToChangelogFile'])
   change.resourceAccessor = resourceAccessor
   addChange(change)
 }

changelog changeSet(author: "erwin", id: "1"){ sqlFile(path: "dump.sql", stripComments: true, splitStatements: true, endDelimiter: ";", encoding: "utf8", relativeToChangelogFile: false) }

changeSet(author: "erwin", id: "2"){
    sqlFile(path: "dump1.sql", stripComments: true, splitStatements: true, endDelimiter: ";", encoding: "utf8", relativeToChangelogFile: true)
}

It works on my fork, so just a little change.

ErwinvanBrandwijk commented 13 years ago

Closing this issue. Solved.

relativeToChangelogFile has his own issue.