[Schevo-devel] [EVALUATION] - How to Evolve a Database
Patrick K. O'Brien
pobrien at orbtech.com
Tue Mar 7 08:31:06 EST 2006
Ilias Lazaridis wrote:
> My second question is:
>
> how do I evolve a database schema?
>
> e.g. I've added one class to my schema.
>
> created the database, added some instances.
>
> add a new class to the schema.
>
> Now I want to update the underlying database.
>
> something like:
>
> evo evolve eval.db
>
> How do I do this?
Our support for schema and database evolution is rather limited at this
point. We had more support for it in "Schevo2", but learned from that
and created better infrastructure for evolution in the current
"Schevo3". Now we just need time to take advantage of this
infrastructure. In the mean time, I have two suggestions.
For early development where you want maximum flexibility I recommend
taking full advantage of the ability to specify initial and sample
values within your schema and using that schema to create a new database
each time you change your schema. This approach has worked well for me.
Once you outgrow that approach, we do have support for "intra" schema
changes. By that I mean that if you make a simple change, like adding a
new Entity class or new field, you can update an existing database.
Right now you do that by using the same "evo db create ..." command and
specifying an existing database file name (yes, it is an ugly,
misleading hack, but it works). The exact set of upgradeable things is
not clearly documented either, unfortunately.
Alternatives beyond these two require a bit of creativity. For example,
you could create a new database with the new schema and write a script
that opens up both the old and the new database, iterates over the old
stuff and creates objects in the new database. I've done that before.
We also have support for XML/SQL export and import that could be used.
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com
Schevo http://www.schevo.org
Louie http://www.pylouie.org
More information about the Schevo-devel
mailing list