I do something similar to both Eric and Maniac, e.g. I create SQL
language files which contain ALTER TABLE and similar statements, and
apply those to a 'base' database to transform it into the most recent
version without losing data. I haven't automated it yet like Eric
has, but it won't be too difficult to accomplish when I want to.
Regards,
Jeff
On Jan 18, 2006, at 4:04 PM, Eric Walstad wrote:
Luke Skibinski Holt wrote:
...
I'm just looking for a quick way to update my models in the
development
stage while keeping test data.
Hey Luke,
I keep sample/test data in sql files and have a script that reloads
that data into my database. The script:
- recreate the app's database (dropdb, createdb)
- initialize the django tables (django-admin.py init)
- install the admin and app projects (django-admin.py install admin,
etc)
- load all the sql files found in some/path/to/sql/files/ in alpha
order
I keep the sql files in a directory and I name them in such a way that
they will be loaded back into the database in the order I need:
$ ls -1
100_users.sql
150_addresses.sql
...
550_customers.sql
600_applications.sql
...
900_notes.sql
950_state_histories.sql
I wrote a simple bash script to handle the drudgery. The heart of the
script, the part that loads the sql, looks like this:
for SQL_FILE in $APP_SQL/*.sql
do
echo
echo " Loading $SQL_FILE"
su - $USER_NAME -c "psql $APP_NAME < $SQL_FILE"
done
which loads all my data. The rest of the script collects info from
the
user regarding paths to django-admin.py, repository trunk and database
user, etc., then runs the database and django-admin.py commands to
drop/create the db and init and install django apps.
When our schema changes, I edit the appropriate sql file to match the
new schema. Then I run my 'complete_rebuild' script. Each member of
the development team has a copy of the script so that if any of us
changes the sample/test data, the rest can quickly and easily
synchronize our local database with the new changes. We occasionally
make changes to our schema, but frequently change the sample data to
exercise testing edge cases. This approach has worked well for us
during development. It allows us to have a common starting point of
data and a fast and easy way to rebuild the application during
development.
I hope that helps.
Eric.
--
Jeffrey E. Forcier
Research and Development
Stroz Friedberg, LLC
15 Maiden Lane, 12th Floor
New York, NY 10038
[main]212-981-6540 [direct]212-981-6546
http://www.strozllc.com
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No right to
confidential or privileged treatment of this message is waived or lost
by any error in transmission. If you have received this message in
error, please immediately notify the sender by e-mail or by telephone at
212.981.6540, delete the message and all copies from your system and
destroy any hard copies. You must not, directly or indirectly, use,
disclose, distribute, print or copy any part of this message if you are
not the intended recipient.