this is my problem I have this project that host document templates in database (CLOB) and when a change is made we have to promote to all changes to all environments.
I'm looking for a solution where when a change is done to a template file this gets promoted to all registered databases using mybatis migration tool, flyway or something similar so it can be integrated with a continouos integration tool.
I haven't seen any documentation where something like this is possible neither in mybatis nor flyway (maven plugins)
I'm thinking it is something like this:
<<migration.sql file>>
--:content1=file://somelocation/file
insert into clob_table (id, content) values (clob_table_sequense.nextval, :content1)
Thanks on advance your comments
Speaking from the Flyway perspective, this can be easily achieved using Java Migrations
Related
For my application,i am using multiple databases.I want to run/upgrade schema for all those databases from one place(for management purpose).It is cumbersome process(specially in production/integration phase) to go to all databases and run/upgrade schema after every release or whenever some changes in schema.We thought of using simple docker for this purpose.
Anyone has idea whether is it good idea or not ?If possible please suggest how it can be done ?
I would like if any other suggestions are there.
As suggested by #markc, it is a matter of scripting only.Connect to all database and run schema on them.Used golang as language and built docker for that.
I know this is a duplicate question.
But even i couldn't find any tool to create JPA entity file from database source.
I used eclipse to do this. I only got DTO kind of classes with getters & setters.
Can anyone suggest some tools that create DAO files too.
TIA
You can use Telosys Tools,
an Eclipse plugin working from an existing database with customizable Velocity templates
See: https://sites.google.com/site/telosystools/
Eclipse Marketplace : http://marketplace.eclipse.org/content/telosys-tools
For JPA generation, use the JPA set of templates available on GitHub : https://github.com/telosys-tools
you can use netbeans instead of eclipse. After you create own project, you can select "JPA controller classes from entity classes" in netbeans menu. For example http://ensode.net/roller/dheffelfinger/entry/automated_dao_generation_from_jpa
Minuteproject is a generator tool and can generate JPA2 artifacts from Database.
You can instruct the generator to apply convention for your java code that do not follow your DB convention, but the mapping will be correct. (Example strip DB name prefix; table starting with ADMIN_ such as ADMIN_ENVIRONMENT are Environment (w/out Admin) as java class) For the moment there 20+ conventions that help you reshape your model to be less DB look-and-feel by more Java-OO-friendly.
If you want DAO minuteproject has a track BSLA that generate spring-integrated DAO
There are at least two Grails plugins that emulate the database migration functionality of Rails:
Autobase
Liquibase
Is there a consensus about which of these is best, or is there another plugin that does database migration better than either of the above?
There is now a standard Grails database migration plugin available. According to this blog post at least the liquibase plugin will therefore not be maintained past the liquibase 1.9 release anymore.
The new database migration plugin has built-in functionality to execute changelogs on startup and supports the definition of changes in Groovy DSL, so it's probably what you are looking for.
I use Autobase (which is built on top of Liquibase) as it (last time I checked) allows you to automatically check/apply your migrations when the app starts. With the Liquibase plugin I have to do this myself in servlet init code. This allows you to set your datasource to dbCreate = none and let Autobase handle getting the DB into shape.
It does mean you need to write a migration each time you add a property to a domain class, but I think this is a good thing as it makes you think about what the underlying field should actually be instead of just letting Hibernate take a guess at it.
I think some of the Autobase plugin (e.g. the groovy dsl) is being migrated back to the Liquibase plugin, but you'd need to check up on that.
The only downside to Autobase is the lack of good documentation. There is some but it's not complete. Luckily, the dsl is the same as the xml Liquibase tags so you can work most of it out.
I use liquibase, I'm not sure that Robert is still actively maintaining Autobase and the xml that liquibase provides is actually pretty DSL-like. I think it also gives a little bit of separation to your database commands and doesn't make it ingrained into the start-up process (some people might prefer the reverse).
At least as of Grails2.0, the database migration plugin is the defacto way to handle non-trivial database changes. The plugin is built on Liquibase, and is authored by the Springsource folks - always a mark of quality. I wrote an introduction to the database migration plugin which might be of use to someone reading this.
I have heard that Autobase is still maintained, but consider that the Grails Database Migration Plugin is written by the core team, and likely going to be the officially supported one.
In other words, encourage you can wait on Grails 1.4 --> roadmap before choosing either of the plugins above.
YEs i also see the migration pluging. This is helpful...
http://grails-plugins.github.io/grails-database-migration/
I'm using the GDR release of VSTS Database edition source control the DB and generate deployment scripts. It works pretty well but the problem is that it only seems to handle scripting and deploying the schema. It stops short of handling scripting and deployment of the actual data itself (i.e. the lookup and standing data which also deployed with the DB).
I know it's easy enough to write the deployment scripts by hand, but is this what every one does? Is there a recommended way of deploying data with the VSTS deployment engine? Is there some tooling that help with this - I don't mean a full product like SQLCompare, just something that fills the gap with VSTS DB.
Thanks in advance.
Kaneda
The VSTS: DB best practices blog advocates using post-deployment scripts to insert reference data into temporary tables, then update the target tables based on the delta (ie update x inner join temp where x.something <> temp.something)
There's some suggestions floating around that this might make a powertool, and at least one MVP has written a tool to generate those scripts.
(NB: I haven't tried this - I only just found out about it myself)
Personally I would still stick with RedGate if I had any choice in the matter.
GDR comes with a data comparison engine, but as far as I've been able to tell so far a data comparison can't even be stored in a project (let alone be properly supported by it) - so it's pretty ad-hoc. Unlike a Schema Compare, there is no File \ Save As.
The comparison engine can be automated via DDE but that's automation within the Visual Studio IDE, and not really suitable for some kind of scripted installation process. As much as anything there's no way I could see to specify which tables to include in the comparison (since all you get to do via DDE is open the wizard for the user to select)
Alternatively all the functionality appears to reside in Microsoft.VisualStudio.TeamSystem.DataPackage.dll , but since the API documentation hasn't been written yet (the help doco that comes with GDR is full of errors as it is) it's going to be a bit of a hit-and-miss adventure to work out where to start.
As someone who's used RedGate's SqlCompare, SqlDataCompare and their respective APIs to do this before, much of the GDR functionality seems a bit half-baked to me.
What I will probably do this time round is sync the data with a SSIS package (export to CSV at build time / import from CSV at install time), but I'd far rather be using the SqlDataCompare API (or SqlPackager) right now.
Sorry if this is overly simplistic.
I've decided that I want to use an SQLite database instead of a MySQL database. I'm trying to wrap my head around how simple SQLite is and would like a simple, one answer tutorial on how to use SQLite with the Zend Framework, where to put my SQLite database in my directory structure, how to create the database, etc.
#tuinstoel is correct, attaching to an SQLite database implicitly creates it if it does not exist.
SQLite also supports a command-line client that is more or less like MySQL's command shell, allowing you to issue ad hoc commands or run SQL scripts. See documentation here: http://www.sqlite.org/sqlite.html
Of course you need to change the Zend_Db adapter in your ZF application. ZF supports only an adapter to the PDO SQLite extension. SQLite doesn't support user/password credentials. Also since SQLite is an embedded database instead of client/server, the "host" parameter is meaningless.
$db = Zend_Db::factory("pdo_sqlite", array("dbname"=>"/path/to/mydatabase.db"));
One more caveat: when you get query results in associative-array format, some versions of SQLite insist on using "tablename.columnname" as the keys in the array, whereas other brands of database return keys as simply "columnname". There's an outstanding bug in ZF about this, to try to compensate and make SQLite behave consistently with the other adapters, but the bug is unresolved.
If you make a connection to a not existing database, a database is created on the fly. (You can turn this behavour off)
This is now covered in the Zend Framework quickstart tutorial (version 1.9.5 as of this writing). Just make a new project (with zf command line tool. look here for a great tutorial on setting it up), add these lines to your config.ini file and you're good to go:
; application/configs/application.ini
[production]
resources.db.adapter = "PDO_SQLITE"
resources.db.params.dbname = APPLICATION_PATH "/../data/db/databaseName.db"
Now when you ask for your default database adapter, it will use this one. I would also recommend downloading the quickstart tutorial source code and making use of the load.sqlite.php script. You can create a schema and data file and load the database with these tables/columns/values. It's very helpful! Just check out the tutorial. It's all in there.
This answer was moved out of the question into a CW answer to disavow ownership over the content.