Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2239 (closed enhancement: migrated)

Opened 10 years ago

Last modified 8 years ago

Simplify database migration in TG2

Reported by: chrisz Owned by:
Priority: normal Milestone: 2.2
Component: SQLAlchemy Version: 2.0b6
Severity: normal Keywords: sqlalchemy migrate
Cc:

Description (last modified by jorge.vargas) (diff)

It is recommended to use sqlalchemy-migrate for database migration in TG2. This tool is surely helpful once your application is in production and the database contains real data. But as long as you're under heavy development, you don't want to bring out such big guns - a simpler tool is preferable.

Ideally, I just want to add a new column to a table in my data model, and the tool should automatically add this in the existing database. TG1 provided "tg-admin sql update" for this purpose. Options:

1) We can add such a tool as a paster command (since we have "setup-app", we may want to have "update-app").

2) We can improve sqlalchemy-migrate so that it grows an automatic and semi-automatic mode. My idea is that in the automatic mode, migrate would do something similar to "tg-admin sql update", and in the semi-automatic mode, it would generate upgrade and downgrade scripts that you can modify and improve as you like. Currently you need to manually write upgrade and downgrade scripts. This should be possible with the with the schema reflection features of SA.

Change History

comment:1 Changed 10 years ago by jorge.vargas

+1 on both, with a preference for #2 we'll have to talk to the sa-migrate people to see if they want the contribution.

comment:2 Changed 10 years ago by chrisz

"... with the schema reflection features of SA." I wanted to end my sentence, i.e. by using reflection and comparing the metadata.

comment:3 Changed 10 years ago by jorge.vargas

  • Description modified (diff)

comment:4 Changed 10 years ago by chrisz

I need to correct myself. There was actually never a "tg-admin sql update" command in TG1. I probably confused this with "tg-admin sql status" which detected the changes, but without updating. Or maybe I confused it with "tg-admin sql upgrade", but that worked only for SQLObject and probably needed manually written upgrade scripts as well.

Anyway, this does not change the fact that this would be a highly desirable tool.

comment:5 Changed 10 years ago by jorge.vargas

  • Milestone changed from 2.x to 2.1

comment:6 Changed 10 years ago by jorge.vargas

FYI, SQLAlchemy 0.6 now has some interesting migration capabilities. It is rumored to have a "mini-migration-framework" in the next release.

comment:7 Changed 9 years ago by mramm

  • Milestone changed from 2.1 to 2.2

comment:8 Changed 9 years ago by timblack1

I've wrapped migrate's commands to create a new migration on Ubuntu in the following shell script:

 http://bazaar.launchpad.net/~caneypuggies/reformedchurcheslocator/trunk/annotate/head%3A/new_migration.sh

It might be nice for someone to convert this into Python code so it will run everywhere, and make it a Paster command.

comment:9 Changed 8 years ago by pedersen

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.