On Wed, 7 Jun 2006, sophana wrote:

Rick Flosi a écrit :
On Wed, 7 Jun 2006, sophana wrote:


I'm using sqlobject-0.7
I'm trying to follow the sqlobject-admin documentation

did a
sqlobject-admin record -m Sql
I can see a new table created containing the current version
then I add a column 'foo' to one of my tables


**
You need to do another `sqlobject-admin record` at this point to record
the changes to the schema and use the --edit flag to open and editor so
you can write the upgrade script (SQL Alter statements) which will be used
when you then call upgrade below.
**


write the upgrade script?
I don't understand.
Do you have an example?

So you add field 'foo' to your sqlobject class...

You had:

class MyTable(SQLObject):
    name = StringCol()

you did sqlobject-admin record...

Then you updated to:

class MyTable(SQLObject):
    name = StringCol()
    foo = StringCol()

now you do record again with the --edit flag.
This will open your default text editor and probably include something at the bottome of the text file about the missing field 'foo'. Then you write the SQL needed to get your current database up-to-date with the new schema in this text file. Something like:
    ALTER TABLE my_table ADD foo TEXT;
And save the file which will be written under the previous versions path as upgrade from_old_version_to_new_version.sql

When you then do sqlobject-admin upgrade it will first look at your current version from the database and then look for the upgrade script you just created and call that to upgrade to the current version.
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to