Classes for a DB interface and to automate DB migration
Posted: Thu Jul 15, 2010 8:32 am
This is in early stages, but I'm still keen to get feedback and comments. If others wanted to use it and submit improvements back, that's even better!
It's all BSD Licensed.
The Base class for the DB interface:
http://elastik.svn.sourceforge.net/view ... iew=markup
This grew organically rather than being designed, so some of the names aren't consistent or great – something to fix.
So far there are adaptors for MySQL and MS SQL Server:
http://elastik.svn.sourceforge.net/view ... iew=markup
http://elastik.svn.sourceforge.net/view ... iew=markup
Then the Base class for a Migration:
http://elastik.svn.sourceforge.net/view ... iew=markup
A typical migration looks like:
http://elastik.svn.sourceforge.net/view ... iew=markup
Every DB migration is tracked by date, which makes it easy to have multiple branches of code development with migrations on each one and merge them together later.
And the class to actually perform the migrations:
http://elastik.svn.sourceforge.net/view ... iew=markup
The system it comes from has modules and a core system, so it looks for Migrations in both places and sorts them all together.
Hopefully that's not to much code; sorry …
There is no create schema yet; at the moment it creates the DB from scratch by running through all migrations.
There is also no migrateDown process yet. Personally, while I can see it would be handy I've not been convinced that they are an essential feature. I mean, you did back up the DB before migration, right? I think part of my reluctance will disappear when I work out a neat way of unit testing them.
Anyway, any comments or feedback welcome ….
Thanks,
James
The Base class for the DB interface:
http://elastik.svn.sourceforge.net/view ... iew=markup
This grew organically rather than being designed, so some of the names aren't consistent or great – something to fix.
So far there are adaptors for MySQL and MS SQL Server:
http://elastik.svn.sourceforge.net/view ... iew=markup
http://elastik.svn.sourceforge.net/view ... iew=markup
Then the Base class for a Migration:
http://elastik.svn.sourceforge.net/view ... iew=markup
A typical migration looks like:
http://elastik.svn.sourceforge.net/view ... iew=markup
Every DB migration is tracked by date, which makes it easy to have multiple branches of code development with migrations on each one and merge them together later.
And the class to actually perform the migrations:
http://elastik.svn.sourceforge.net/view ... iew=markup
The system it comes from has modules and a core system, so it looks for Migrations in both places and sorts them all together.
Hopefully that's not to much code; sorry …
There is no create schema yet; at the moment it creates the DB from scratch by running through all migrations.
There is also no migrateDown process yet. Personally, while I can see it would be handy I've not been convinced that they are an essential feature. I mean, you did back up the DB before migration, right? I think part of my reluctance will disappear when I work out a neat way of unit testing them.
Anyway, any comments or feedback welcome ….
Thanks,
James