[Dbix-class] Ideas for database versioning.

Patrick Meidl pmeidl at ist.ac.at
Tue Nov 6 09:21:34 GMT 2012


On Tue, Nov 06 2012, Alexander Hartmaier <alexander.hartmaier at t-systems.at> wrote:

> What about a version table with a single version column that is
> checked at model connect time if the database schema version is what
> the model expects?

I use such an approach.

I have a 'meta' table where is store all sorts of meta information as
key/value pairs. the schema_version is stored there. I write my
migrations as SQL files with a version number in the filename and a
pre-defined comment block at the beginning of the file describing the
patch. a utility script (migrate_db.pl) then looks in the database for
the current version, applies all newer patches, writes the patch
comments in a 'migration' table and bumps the schema_version. works well
for me in combination with the DBIc schema loader (also done by a little
helper script for convenience).

what I do not do yet is check for an expected schema_version in my
application, but that actually sounds like a good idea
(ticket created ;-)

    patrick

-- 
Patrick Meidl, Mag.
Senior Expert Software Engineering

IST - Institute of Science and Technology Austria
Am Campus 1
A-3400 Klosterneuburg, Austria

R 03.EG.003
T +43 2243 9000 1063
E pmeidl at ist.ac.at
W http://www.ist.ac.at/




More information about the DBIx-Class mailing list