Using unitils/dbMaintain to maintain database, how

2019-03-04 21:27发布

问题:

I am using unitils (and its dbMaintain module) to maintain the state of my local database.

dbMaintain has an option to exclude/include scripts based on a qualifier. See http://www.dbmaintain.org/tutorial.html#Qualifier_inclusion__exclusion.

In my project, excludes/includes do not work when running from a Unitils test with the UnitilsJUnit4TestClassRunner.

My script hierarchy:

unitils/ 
    01_create/ <lots of scripts here> 
    02_lkups/ <lots of scripts here> 
    03_#testdata/01_#testdata_master/05_#testdata_master_rate_offer.sql 

My unitils.properties file has:

updateDataBaseSchema.enabled=true
dbMaintainer.script.locations=unitils
dbMaintainer.qualifiers=testdata 
dbMaintainer.excludedQualifiers=testdata 

I would expect 05_#testdata_master_rate_offer.sql to be excluded. But it is being run.

Thanks in advance for any help.

回答1:

Answered by one of the unitils developers on the unitils forums here: http://sourceforge.net/projects/unitils/forums/forum/570578/topic/4546980

Qualifiers are a feature of dbmaintain. Unitils 3.1still contains its own dbmaintainer which still dates from before the split-off of dbmaintain. Unitils 4.0 has this module replaced by a dependency to dbmaintain, but this version is not released yet. I would suggest that, until 4.0 is released, you call dbmaintain directly from your java code. Hope this helps, Filip