nicolas
nicolas

Reputation: 121

Grails Database Migration: Convert xml/groovy diff into sql script file

I'm using Database Migration Plugin for Grails. I just want to know if there is a way to transform the xml/groovy output diff file into a sql script file because is the only way that I can run modifications in the database in the project that I'm working on.

For example, I have this .groovy diff file:

databaseChangeLog = {

    changeSet(author: "nm (generated)", id: "1415018853093-1") {
        createTable(tableName: "configuration_variable") {
            column(autoIncrement: "true", name: "id", type: "bigint") {
                constraints(nullable: "false", primaryKey: "true", primaryKeyName: "configurationPK")
            }

            column(name: "version", type: "bigint") {
                constraints(nullable: "false")
            }

            column(name: "name", type: "varchar(255)") {
                constraints(nullable: "false")
            }

            column(name: "value", type: "varchar(255)") {
                constraints(nullable: "false")
            }
        }
    }

    changeSet(author: "nm (generated)", id: "1415018853093-2") {
        createIndex(indexName: "name_uniq_1415018853044", tableName: "configuration_variable", unique: "true") {
            column(name: "name")
        }
    }
}

Upvotes: 1

Views: 337

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

Take a look at the documentation for the plugin. You may find that using the dbm-update-sql command will give you the SQL output that you need to manually execute the changes against your datasource.

Also the dbm-changelog-sync-sql command may be useful in your case as well.

Upvotes: 1

Related Questions