Merge remote-tracking branch 'khusha/FlywayWrapperTasksForDBMigration'
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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 {
|
||||||
@@ -191,7 +195,7 @@ task deployPentahoReports() {
|
|||||||
|
|
||||||
war {
|
war {
|
||||||
it.dependsOn deployPentahoReports
|
it.dependsOn deployPentahoReports
|
||||||
from ('../mifosng-db/migrations') {
|
from ('../mifosng-db/migrations/core_db') {
|
||||||
into "WEB-INF/classes/sql"
|
into "WEB-INF/classes/sql"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,58 @@ 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 migrateTenantDB<<{
|
||||||
|
description="Migrates a Tenant DB. Have to pass dbName. (Example: -PdbName=someTenantDBname). "
|
||||||
|
|
||||||
|
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
|
||||||
|
flyway.locations= [
|
||||||
|
"filesystem:../mifosng-db/migrations/core_db",
|
||||||
|
]
|
||||||
|
|
||||||
|
flywayMigrate.execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
task showTenantDBInfo<<{
|
||||||
|
description="Shows the migration info for a Tenant DB. Have to pass dbName. (Example: -PdbName=someTenantDBname)"
|
||||||
|
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
|
||||||
|
flyway.locations= [
|
||||||
|
"filesystem:../mifosng-db/migrations/core_db",
|
||||||
|
]
|
||||||
|
flywayInfo.execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task migrateTenantListDB<<{
|
||||||
|
description="Migrates a Tenant List DB. Have to pass dbName. (Example: -PdbName=someDBname)"
|
||||||
|
|
||||||
|
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
|
||||||
|
flyway.locations= [
|
||||||
|
"filesystem:../mifosng-db/migrations/list_db",
|
||||||
|
]
|
||||||
|
|
||||||
|
flywayMigrate.execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
task showTenentListDBInfo<<{
|
||||||
|
description="Shows the migration info for a List DB. Have to pass dbName. (Example: -PdbName=someDBname)"
|
||||||
|
flyway.url= "jdbc:mysql://localhost:3306/$dbName"
|
||||||
|
flyway.locations= [
|
||||||
|
"filesystem:../mifosng-db/migrations/list_db",
|
||||||
|
]
|
||||||
|
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user