[Khushal/Priti] Modified build.gradle to have tasks for migrating both types of DB. Added migrateDB and showDBInfo with params as DB name. They wrap over flyway so that one can pass DB name as param. Also seperated the migration folder into list_db and core_db so that migrations for tenant list and core tenent db can be placed in different folders.

This commit is contained in:
Khushal Oza
2013-04-04 12:21:18 +05:30
parent 9652844889
commit 8956ef35a3
8 changed files with 151 additions and 36 deletions
File diff suppressed because one or more lines are too long
+41 -15
View File
@@ -56,6 +56,10 @@ project.ext.hibernateCoreVersion = '4.2.0.Final'
project.ext.jerseyVersion = '1.17' project.ext.jerseyVersion = '1.17'
project.ext.springDataJpaVersion = '1.2.1.RELEASE' project.ext.springDataJpaVersion = '1.2.1.RELEASE'
project.ext.mysqlUser='root'
project.ext.mysqlPassword='mysql'
group = 'org.mifosplatform' group = 'org.mifosplatform'
repositories { repositories {
@@ -263,19 +267,21 @@ configurations.driver.each {File file ->
loader.addURL(file.toURL()) loader.addURL(file.toURL())
} }
task createDatabase<<{ task createDB<<{
description= "Creates the Database mifosplatform-tenants and mifostenant-default" description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', 'root', 'mysql', 'com.mysql.jdbc.Driver' ) sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute( 'create database `mifosplatform-tenants`' ) sql.execute( 'create database '+"`$dbName`" )
sql.execute( 'create database `mifostenant-default`' )
} }
task dropDatabase<<{
description= "Drops the created Databases mifosplatform-tenants and mifostenant-default"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', 'root', 'mysql', 'com.mysql.jdbc.Driver' )
sql.execute( 'DROP DATABASE `mifosplatform-tenants`' )
sql.execute( 'DROP DATABASE `mifostenant-default`' )
task dropDB<<{
description= "Drops the specified database. The database name has to be passed (like: -PdbName=someDBname)"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute( 'DROP DATABASE '+"`$dbName`")
}
task setBlankPassword<<{
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute('USE `mifosplatform-tenants`')
sql.execute('UPDATE mifosplatform-tenants.tenants SET schema_server = \'localhost\', schema_server_port = \'3306\', schema_username = \'mifos\', schema_password = \'mysql\' WHERE id=1;')
} }
@@ -294,17 +300,37 @@ buildscript {
flyway { flyway {
url = "jdbc:mysql://localhost:3306/mifostenant-default" url = "jdbc:mysql://localhost:3306/mifostenant-default"
user = 'root' user = mysqlUser
password = 'mysql' password = mysqlPassword
locations = [ locations = [
'filesystem:../mifosng-db/migrations', 'filesystem:../mifosng-db/migrations',
] ]
//$dbName $dbUser $dbPassword
} }
task migrateDB<<{
description="Migrates the DB. Have to pass dbName and folder name where the .sql file are kept for that DB. (Example: -PdbName=someDBname -PmigrationScriptFolder=someFolderName). "
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
flyway.locations= [
"filesystem:../mifosng-db/migrations/$migrationScriptFolder",
]
flywayMigrate.execute()
}
task showDBInfo<<{
description="Shows the migration info for a DB. Have to pass dbName and folder name where the .sql file are kept for that DB. (Example: -PdbName=someDBname -PmigrationScriptFolder=someFolderName)"
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
flyway.locations= [
"filesystem:../mifosng-db/migrations/$migrationScriptFolder",
]
flywayInfo.execute()
}
/* /*
* Support publication of artifacts versioned by topic branch. * Support publication of artifacts versioned by topic branch.
* CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time. * CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time.