Database schema change - new application version behavior

Ruslan Zasukhin sunshine at public.kherson.ua
Fri Dec 12 13:02:30 CST 2003


on 12/12/03 12:19 AM, Srinivas Yalamarti at syalamar at fiberlink.com wrote:

Hi Srinivas, 

> I have a database dbFirstLast.vdb and other files
> that I created using the following schema
> 
>    class CCustomer :  public VDK_BaseObject
>    {
>          public:
>                VDK_VarChar       m_strFirstName;
>                VDK_VarChar       m_strLastName;
> 
>      public:
> 
>           CCustomer(void):VDK_BaseObject("CUSTOMER"),
>           m_strFirstName("FirstName"),
>           m_strLastName("LastName"),
>           {
>           }
> 
>           virtual ~CCustomer(void) {};
>    };
> 
>    class CClientDB : public VDK_DataBase
>    {
>     public
>           // Statically define the tables in the database:
>           CCustomer                     mCust;
>    };
> 
> And we changed the CCustomer base object to have another
> field, 'customer address'.  And then compiled/linked our code
> with the newer schema.
> 
> When I run the new version of our application, and we try to
> OPEN the old database, will I have any problems?

Yes. 

> If there is going to be a problem, is there anyway I can open
> an existing database without again specifying the schema
> and go thru' the base object - dynamically?

Yes, you can always open ANY db in dynamic way not using classes.
And this is KEY to your task..

You need do

    VDK_database db.
    ^^^^^^^^^
    
    db.Open()

    if( db.SchemaVersion == 1 )
    {
        correct db structure here
        db.SchemaVersion = 2
        db.Close
    }        


    CClientDB db2;

    db2.Open()      -- now all right, classes and db files are the same




-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list