Re: best practice for handling database schema changes

From: Tobias SCHOESSLER (Tobias.Schoessle..nvienna.org)
Date: Mon Dec 04 2006 - 04:44:50 EST

  • Next message: Juergen Saar: "Problem: Ordering.orderList and date-values"


    I see this discussion very interesting, but my initial question was less how to manage the schema changes of the database, than how to manage the cayenne mapping changes. I wonder what are the difficulties in implementing a merge of changes found in the db schema into an existing mapping when performing the 'reverse engineer from database function' in the modeller .
    Merging db schema changes into the mapping information seems to be a common operation and I wonder why it hasn't been implemented in cayenne just yet.  Especially as cayenne seems to have a strong emphasis on the usability of the mapping process with its integrated modeller. Something I recall other ORM tools don't have at all (e.g. hibernate).

    (I would never ask this on a commercial help forum, nor expect a true answer ; )  ), but what about the competitors ? Is this 'merge schema changes into existing mapping' feature so exotic that it is not adhoc supported in other ORM tools?

    regards

    Tobias



    "Malcolm Edgar" <malcolm.edga..mail.com>

    Sunday, 3 December 2006 23:49
    Please respond to
    cayenne-use..ncubator.apache.org

    To
    cayenne-use..ncubator.apache.org
    cc
    Subject
    Re: best practice for handling database schema changes





    I have also used a very similar approach on another project.  We used
    Java commands to perform each version update, the advantage of this
    over straight SQL files is that you can migrated data using Java logic
    into the new schema.

    regards Malcolm

    On 12/4/06, Aristedes Maniatis <ar..sh.com.au> wrote:
    > Interesting article. We implemented something similar, but without
    > hard coding the SQL to update the schema into Java. Instead we have a
    > folder full of files named 1.sql, 2.sql, etc. Each one contains the
    > SQL required to update the database schema. Every time the server
    > application runs it reads a special table in the database with one
    > column and one record. That value is the 'schema version' from the
    > last launch of the application. If this number is lower that the
    > largest xx.sql file in the folder, then that sql file is executed and
    > the version updated.
    >
    > We do all this before Cayenne is intialised in any way in our
    > application.
    >
    > The only thing we haven't yet done is to write a junit test that
    > validates the sum total of all our incremental updates is the same as
    > a single SQL export from the current Cayenne model.
    >
    > Ari Maniatis
    >
    >
    > On 02/12/2006, at 12:56 AM, Michael Gentry wrote:
    >
    > > I found this yesterday (although I haven't read it all yet):
    > >
    > > http://www.stepwise.com/Articles/2005/DBChanges/index.html
    > >
    > > Not sure if it'll be helpful, but it looks similar to some ideas I had
    > > been pondering in the past.
    > >
    > > /dev/mrg
    > >
    > >
    > > On 11/30/06, Michael Gentry <blacknex..mail.com> wrote:
    > >> Currently you have to manually merge the changes just as you states.
    > >> I should probably make an FAQ for this ...
    > >>
    > >> Thanks,
    > >>
    > >> /dev/mrg
    > >>
    > >>
    > >> On 11/30/06, Tobias SCHOESSLER <Tobias.Schoessle..nvienna.org>
    > >> wrote:
    > >> >
    > >> > hi,
    > >> > What is the best practice for handling changes to the database
    > >> schema once a
    > >> > cayenne mapping was created?
    > >> > We use the 'reverse engineer from database' feature to create an
    > >> initial
    > >> > mapping. But then we usually have to do manual changes like map
    > >> some pks,
    > >> > add flattened relationships, etc.
    > >> > If then the database schema needs to be changed we usually have
    > >> a problem as
    > >> > 'reverse engineer from database' overwrites everything. There
    > >> seems to be
    > >> > the possibility to replace only selected tables but if you do
    > >> this the
    > >> > relationships are messed up. Is there a way to  merge the
    > >> changes with the
    > >> > current model/mapping?
    > >> >
    > >> > thanks
    > >> >
    > >> > Tobias
    > >>
    >
    >
    >
    >
    >
    > -------------------------->
    > ish
    > http://www.ish.com.au
    > Level 1, 30 Wilson Street Newtown 2042 Australia
    > phone +61 2 9550 5001   fax +61 2 9550 4001
    > GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
    >
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Dec 04 2006 - 04:45:32 EST