On Mon, Apr 19, 2010 at 04:11:09PM +0300, Imri Goldberg wrote:
> Re using sqlobject-admin: I'm curious - what is your preferred way of
> managing db migrations (i.e. versioning schema changes)?

   I seldom do a simple ADD/DELETE COLUMN. Usually when I change the schema
it's more like "collect some info, ADD COLUMN, put info into the new column".
Something like this (code from a real script upgradedb5.py):

    log.open("upgradedb5.log")

    if db_conn.dbName == 'sqlite':
        db_conn.use_table_info = True

    if 'userID' not in ExportResult.sqlmeta.columns:
        ExportResult.sqlmeta.addColumn(ForeignKey('User', name="user",
                default=None),
            changeSchema=True)

        for result in ExportResult.select(ExportResult.q.plate <> None):
            result.user = result.plate.user

        commit()

    log.close()

   This is a rather simple example. Sometime there is a lot of code to
collect information before schema changing and even more code that puts the
collected information into the new columns.

Oleg.
-- 
     Oleg Broytman            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to