Coder Social home page Coder Social logo

groovy-liquibase's People

Contributors

dstine avatar erwinvanbrandwijk avatar mbruner avatar stevesaliman avatar tlberglund avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

groovy-liquibase's Issues

Boolean defaultValue always interpreted as TRUE

Whenever using a BOOLEAN type in a column, the default value is always interpreted as TRUE. It does not happen for other types, such as BIT or TINYINT.

column(name: "createRight", type: "BOOLEAN", defaultValue: false) { constraints(nullable: false) }

generates the following output:

HSQLDB
createRight BOOLEAN DEFAULT TRUE NOT NULL

MySQL
createRight tinyint(1) NOT NULL DEFAULT '1',

I've also tried other defaultValues such as 'false' "false" 0. All yield the same result.

primaryKeyName constraint doesn't appear to work with addColumn

While trying to replace a primary key column in an existing table, the primary key name for my Oracle and PostgreSQL tables isn't being set (instead the default is used for each DBMS).

I first dropped the existing primary key column using dropColumn:

dropColumn(columnName: 'foo_id', tableName: 'foo')

Then I tried to add the column using addColumn:

addColumn(tableName: 'foo') {
    column(name: 'new_foo_id', type: '${primaryKeyType}') {
        constraints(primaryKey: true, primaryKeyName: 'pk_foo')
    }
}

This creates the primary key, but it doesn't create the primary key name.

To get around this, I did the following:

addColumn(tableName: 'foo') {
    column(name: 'new_foo_id', type: '${primaryKeyType}')
}
addPrimaryKey(columnNames: 'new_foo_id', tableName: 'foo', 
    constraintName: 'pk_foo')

Bug : load data

load data gives an error:

No file opener specified for books.csv

code
resourceAccessor opener = getResourceAccessor
result Null

Windows: saves wrong file location in DB

My colleague is using Windows. He did a build with gradle and had 1 test error about \ \ .
That isn't a big problem. He ran the changeset located in changelogs\changelog.groovy
But when you look in the database it deletes . So = changelogschangelog.groovy

INFO 15-3-11 16:46:liquibase: ChangeSet changelogs\changelog_1.groovy::1::erwin
ran successfully in 194ms

| 1 | erwin | changelogschangelog_1.groovy | 2011-03-15 16:46:16 |

This is really annoying I'm stuck at this point. Rollback won't work because the path.

relativeToChangelogFile

Some tags use relativeToChangelogFile in liquibase core.
It isn't supported in groovy-liquibase.

  • include
  • sqlFile

liquibase.gradle

After clean up.
Some function won't work anymore. example

gradle -q -b liquibase.gradle updateSQL -Dliquibase.count=1

And not all parameters are liquibase.?

IncludeAll tag

Liquibase has an includeAll tag, it isn't possible in groovy-liquibase.

It could be make as his own method or add it to include.

IncludeAll should only read the groovy files in a directory, NOT a subdirectory.

includeAll(path: "/path/")
OR
include(path: "/path/")

Maven support

It works fine with gradle, but we use Maven in "42bv" so we want to have Maven support.

It will make Groovy-Liquibase, easier to adopt for projects.

include does not work relative from changelog file

Whenever a file resource accessor is used with a custom base path, include statements no longer work. This is because the include parser does not use the resource accessor, but new File(params.path), which has no knowledge of our base directory.

Code (DatabaseChangeLogDelegate.groovy - line 94 ~ 101):

def files = []
new File(params.path).eachFileMatch(~/.*.groovy/) { file->
files << file.path
}

files.sort().each { filename ->
includeChangeLog(filename)
}

Build failure in windows

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 6: unexpected char: '' @ line 6, column 20. include(file: 'C:\Users\Erwin\AppData\Local\Temp\liquibase-8652829959237818445.groovy') ^ 1 error

changelogs relative to working directory

We want to use groovy-liquibase outside our svn. If we want to run it, it saves his filepath from where you run groovy-liquibase.

So if another developer want's to update, he has other filepaths and it will crash.

I'm now editing the code to support this.
Change working directory and let groovy-liquibase execute changelogs from the working directory

modifySql tag

modifySql tag isn't supported.

It's used to add sql to a generated SQL script.
Example:
createTable(tableName: "projects"){
column(name: "id", type: "bigint(20)"){
constraints(nullable: "false", primaryKey: "true")
}
column(name: "project_name", type: "varchar(50)")
}
modifySql{
append(value: " DEFAULT CHARSET=utf8")
}

It adds default charset at the end of sql script from create table.
Other possibilities

  • replace
  • prepend

http://www.liquibase.org/manual/modify_sql

Bug : sqlFile change

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.

Version 0.7.6 breaks old behavior of the databaseChangeLog's include tag.

The behavior of the include(path: "some/path/to/changesets") tag of dabaseChangeLog has changed significantly since the 0.7.3 release. In the 0.7.3 release, only groovy files in the given path were included, and they were included in alphabetical order.

Release 0.7.6 Includes all files in the given directory, and in no particular order. This breaks change logs that were counting on the changesets being run in a particular order, which is how I think most people use changesets. There will also be errors if the given directory contains other files, such as backup files, documentation in text files, or even .swp files that exist if the user has a changeset file open in the editor.

There is a workaround:

databaseChangeLog {
  include(path: "some/path")
}

can be replaced with

databaseChangeLog {
    def filenames = []
    def dirname = "src/main/db/changelogs"
    new File("some/path").eachFileMatch(~/.*\.groovy/) { f ->
        filenames << f
    }
    filenames.sort().each() { f ->
        include(file: "some/path/${f.name}")
    }
}

This works, but it is a bit messy and I think we should consider reverting back to the old behavior. I can submit a pull request if you agree.

Steve

Support for groovy change -> customChange

There is now a customChange without code.
It should allow:

  • Groovy code, that will only be executed if it's in the customChange.
  • accessibility to the database. SQL.
  • Possibility to use the re factorings from liquibase in the customChange, example addColumn.

You could take a look at the grails plugin, he has a GrailsChange.

Support for Liquibase 3.0

Now that Liquibase has released version 3.0, I think the DSL (and the gradle plugin) should support it.

I've tried building this project against Liquibase 3, but unfortunately they have changed some things in Liquibase and the build now fails.

I'm happy to help out with the coding. I've got copies of Liquibase, the grooby-liquibase DSL, and the gradle liquibase plugin. I don't know all the nuances of Liquibase itself or what is required of a DSL, so I'd need someone to collaborate with, who could point me in the right direction.

Steve

oracle driver not found even though it is in classpath

When adding a classpath dependency on the ojdbc6 jar (classpath 'com.oracle:ojdbc6:11.2.0.2.0') and running updateSQL, I'm getting the following error:

"Liquibase Update Failed: Cannot find database driver: "oracle.jdbc.OracleDriver" "

Running in debug mode, I see the ojdbc jar is in the classpath. If I run with Java (taking gradle out of the picture), it finds the driver but fails trying to parse the changelog.groovy file. Running within gradle seems to be having some kind of issue with the lifecycle related to the oracle driver.

Cheksum errors after upgrade

I just upgraded the liquibase plugin from version 0.6.1 to version 0.7, which uses a newer version of the groovy-liquibase DSL. I am now get checksum errors when I try to run "gradle update". The error is with an old changeSet:

changeSet(id: '25.9.7-base-action_output-constraints', author: 'various (generated)') {
    addForeignKeyConstraint(
        baseColumnNames: 'Action_Output_Type_Id',
        baseTableName: 'action_output', constraintName: 'FK_Action_Output_Action_Output_Type_Id',
        deferrable: false,
        initiallyDeferred: false,
        onDelete: 'NO ACTION',
        onUpdate: 'NO ACTION',
        referencedColumnNames: 'Id',
        referencedTableName: 'action_output_type',
        referencesUniqueColumn: false)
  }

The crux of the problem seems to be with that last bit. I added some logging to Liquibase's MD5Util class to see what was being passed for checksumming. In version 0.7.3 of the DSL, the referencesUniqueColumn parameter is not passed to the checksum routine, but in 0.7.6, it is. This causes a checksum mismatch. I noticed that ChangeSetDelegate.groovy line 269 changed between these versions. What I can't quite figure out is if this is a bug introduced, or a bug fixed.

Can you help shed some light on the subject?

Steve

Bug : delete data

changeset
changeSet(author: "erwin", id: "1"){
delete(tableName: "books"){
where("id=8")
}
}

RESULT
String index out of range: -1

Constraints limited

Not all column constraints from liquibase core are in this plugin
Code of liquibase core:
public class ConstraintsConfig {

private Boolean nullable;
private Boolean primaryKey;
private String primaryKeyName;
private String primaryKeyTablespace;
private String references;
private Boolean unique;
private String uniqueConstraintName;
private String check;
private Boolean deleteCascade;
private String foreignKeyName;
private Boolean initiallyDeferred;
private Boolean deferrable;

code of plugin

constraint = new ConstraintsConfig(primaryKey: false,
                                   unique: false,
                                   deleteCascade: false,
                                   initiallyDeferred: false,
                                   deferrable: false,
                                   nullable: true)

}

Already working on solution, adding those other constraints and testing

RDBMS conditional

Allow specific sections of a change log to be used for only one type of RDBMS. This would allow us to do things such as:

changeSet() {
createTable(tableName: "address") {
column(autoIncrement: true, name: "id", type: "BIGINT") {
constraints(nullable: false, primaryKey: true)
}
}
rdbms('hsqldb') {
sql('x')
} other {
sql('y')
}
// do something else
}

So, the following change sets would be semantically equal:

changeSet(rdbms: 'mysql') {
...
}

changeSet() {
rdbms('mysql') {
...
}
}

Use with a liquibase plugin

I'd like to write my liquibase changelogs using this groovy-dsl, but it is not obvious whether or not it supports liquibase plugins. If it does, an example should be added to the documentation. If it does not, support should be added along with an example.

Thanks for taking a random request from a stranger.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.