Executing the same query for different DBs

16 views
Skip to first unread message

Christian Mierez

unread,
Apr 13, 2015, 12:20:58 PM4/13/15
to jooq...@googlegroups.com
Hi everyone,

We are using jOOQ in most of our projects (Java + Maven) of Test Engineering. Some of our projects need to execute their test scripts for different environments (QA, staging, prod). Having said that, the challenge we have been facing lately is the following:  

Every db schema is already created (qa, staging and prod) and located in different paths by environment (e.g: db.model.dbschema-{environment}.dbname.table). 

We have a layer for managing all our queries but the problem comes up when changing the environment because the imports are different according to the DB: 

//Prod
import db.model.dbschema-prod.dbname.table1
import db.model.dbschema-prod.dbname.table2

//Staging
import db.model.dbschema-staging.dbname.table1
import db.model.dbschema-staging.dbname.table2 

//QA
import db.model.dbschema-qa.dbname.table1
import db.model.dbschema-qa.dbname.table2

So if we want to run our tests against prod we have to comment staging and QA imports. 

We have thought to split up the DB layer in 3 classes, each for environment and then add a new layer to initialize one of those classes according to the environment. I do not like the idea of having repeated code in 3 classes since the only thing that change is the db-schema. That's why I am creating this topic, I know there might be a fancy solution out there. 

Has anyone of you faced the same "problem"?  How do you solve it? 

Just let me know I wasn't clear enough and I will be happy to explain it in a better way. 

Thanks, 

Lukas Eder

unread,
Apr 14, 2015, 3:13:47 AM4/14/15
to jooq...@googlegroups.com
2015-04-13 18:04 GMT+02:00 Christian Mierez <christia...@groupon.com>:
We have thought to split up the DB layer in 3 classes,

Reply all
Reply to author
Forward
0 new messages