Re: Schema Evolution

From: Jonathan Carlson (Jonathan.Carlso..atun.com)
Date: Mon Jul 26 2004 - 10:43:19 EDT

  • Next message: McBrayer, Roy: "Ordering string represntations of numbers"

    Thanks Andrus,

    I think you are on the right path of making simple things easy and difficult things possible. Adding a column is a relatively simple thing and it should be easy for Cayenne to do. I specifically chose Cayenne because it makes easy the tedious, yet relatively simple, 90% of data mapping tasks. I can handle the other 10% myself.

    I also think you are right that it would be highly impractical to have Cayenne attempt to tackle complex schema migrations. I think it would add more complexity to the tool than it would provide benefit. That's what SQL is for, IMO.

    My 2 cents,

    Jonathan

    >>> Andrus Adamchik <andru..bjectstyle.org> 2004-07-23 4:54:04 PM >>>
    Hi Jonathan,

    As this raises a valid concern, it can't be "too critical" ;-) BTW,
    this has been discussed multiple times in the last few months. So....

    1. You are right - current Cayenne schema generation is all or nothing.
    You can drop and recreate your tables but there is no "merge".

    2. In the future we will definitely improve that. This is in the plans.
    However there is a huge BUT, which lead us to (3)...

    3. In a general case "merging" DB schema with the evolved model is not
    just add/drop column. Most real life migrations between schema versions
    are incomparably more complex than that. They involve moving data
    within and between tables, modifying this data in the process,
    intermingling DDL and DML statements, and is generally impossible to
    automate.

    In my work as a consultant, I've spent a fair amount of time on various
    projects trying to automate or at least improve tedious database schema
    upgrade process between the code versions. My conclusion is that full
    generic (and most importantly - working) automation is impossible. If
    you have a production DB with lots of data, expect doing manual SQL
    coding. Somebody please prove me wrong on that!

    On a more optimistic note, we can still *greatly* improve this
    experience by providing a dumb generated "SQL patch" that compares
    current DB state and current Cayenne DataMap, and generates "create
    table/add column/drop column" statements without regards to the actual
    data migration path... It can be saved and later manually customized
    for the actual DB run. That's where we are heading.

    A bit unrelated, I guess I should follow the suggestion made privately
    by Michael Gentry and set up a Wiki for Cayenne, so that such
    discussions could leave a trail and an actual implementation roadmap.

    Thanks
    Andrus

    On Jul 23, 2004, at 5:20 PM, Jonathan Carlson wrote:

    > I hope I didn't sound too critical in my note below. Cayenne is a
    > very easy to use tool and I'm sure it will only get easier to use as
    > time goes on. My thinking that Cayenne might make this really easy
    > for me is a testament to how easy it is already.
    >
    > As I thought about it I realized that adding a column could be a
    > difficult thing for Cayenne to manage if the column was mandatory
    > because Cayenne does not yet allow a default value specification. I'm > hoping that specifying a default value will be a new Cayenne feature
    > soon since it seems like a useful feature and all databases (I think)
    > support it at some level.
    >
    > Are these features "on the horizon" or "down the road further"?
    > (default column specification, and smarter schema evolution)
    >
    > Thanks,
    >
    > Jonathan
    >
    >
    >>>> "Jonathan Carlson" <Jonathan.Carlso..atun.com> 2004-07-23 1:37:07
    >>>> PM >>>
    > I did a quick test to see how Cayenne handled adding a new field when
    > there was data already in the table. I was secretly hoping that
    > Cayenne would do the right thing and generate an add column statement
    > rather than a create table statement, but it didn't.
    >
    > To top it off, clicking on the "Generate" button resulted in a "Schema > Generation Complete" message as if the db schema now matched what was > in Cayenne, which it didn't because no column was added.
    >
    > Is this a bug or just a missing feature? What's the best way for me
    > to handle this situation? Add columns manually?
    >
    > Thanks in advance!
    >
    > Jonathan
    >
    >
    >
    >
    >
    > *********************************************************************** > **********
    > This email and any files transmitted with it are confidential and
    > intended solely for the use of the individual or entity to whom they
    > are addressed. If you have received this email in error please notify
    > the system manager.
    >
    > Katun Corporation -- Celebrating 25 Years of Service
    > www.katun.com
    > *********************************************************************** > **********
    >
    >
    >
    >
    > *********************************************************************** > **********
    > This email and any files transmitted with it are confidential and
    > intended solely for the use of the individual or entity to whom they
    > are addressed. If you have received this email in error please notify
    > the system manager.
    >
    > Katun Corporation -- Celebrating 25 Years of Service
    > www.katun.com
    > *********************************************************************** > **********
    >
    >

    *********************************************************************************
    This email and any files transmitted with it are confidential and
    intended solely for the use of the individual or entity to whom they
    are addressed. If you have received this email in error please notify
    the system manager.

    Katun Corporation -- Celebrating 25 Years of Service
    www.katun.com
    *********************************************************************************



    This archive was generated by hypermail 2.0.0 : Mon Jul 26 2004 - 14:43:44 EDT