It is a advisable idea that you keep your bootstrap file tiny ...no too much code inside and that good approach to follow , yours.
So , what you need is try to create a new migration scrip
file
even if you didn't have a change in your DOMAIN
. Since ,this will help you add your sql script and then later will not execute them at every start up if they are once successfully created.
TODO on grails command line :
grails dbm-create-changelog
grails prod dbm-generate-gorm-changelog --add changelog-1.0.whatevername.groovy
Then ,
add the sql script inside changelog-1.0.whatevername.groovy
file as follow :
1.Using sql file like
//sqlFile( path: "${ path to SQL file relative to changelog.groovy }")
//Used in a changeset, it looks like this:
changeSet(author: "username", id: "1305821637932-1") { //id:is to be changed
sqlFile( path: "books.sql")
}
2.Using by writing the scrip inside
changeSet(author: "username", id: "1305821637932-2") { //id : is to be changed
addColumn(tableName: "book") {
column(name: "flammable", type: "BIT") {
constraints(nullable: "false")
}
}
SQL("UPDATE DatabaseName.TableName1 SET ColumName = 2 WHERE ColumName IN (
SELECT ColumName FROM DatabaseName.TableName2 st WHERE st.ColumName = 'XYZ'))";
SQL("DELETE FROM DatabaseName.TableName2 WHERE ColumName NOT IN (2)");
}