paltman-archive / nashvegas

Another database migration script runner for Django projects.
http://paltman.github.com/nashvegas
MIT License
97 stars 18 forks source link

Calling Django's version of syncdb should still be possible #48

Closed brutasse closed 11 years ago

brutasse commented 12 years ago

Since bf38d077257bd9354c7bbf786288c2697fb0c534, calling syncdb with nashvegas installed calls upgradedb. When creating a new DB from a project that has a lot of migrations, the python migrations which use the project's models are not necessarily in sync with the DB at the time of the migration (for instance, different field names between the DB and the python models), and the project may be in a stage where the database can't even be sync'd.

The larger issue is forward-compatibility of migrations but this is not always possible. Anyway, the migration process should be:

Nashvegas used to warn the user when trying to run syncdb with nashvegas installed, and the usual workflow was to run upgradedb + syncdb on all deploys. This could work very well here, and upgradedb could do the following:

Check if the DB is being synced for the 1st time. If so: do syncdb + seed migrations Else: upgradedb -x && syncdb

This way the user only uses upgradedb, gets a big fat warning when trying to use syncdb directly and upgradedb calls syncdb at the appropriate time.

Thoughts?

46 implements the upgrade case but not the 1st sync case.

brutasse commented 12 years ago

BTW, comparedb is currently broken because of this, it runs the migrations on the _compare database instead of forcing Django's syncdb.

jpic commented 12 years ago

I have to agree with brutasse: hacking syncdb doesn't seem like a good idea at all - it might be seen as "nashvegas breaks django"

paltman commented 11 years ago

I think #52 provides a good compromise to this issue. syncdb by default will running migration, but provides a --skip-migrations flag if you want Django's version. I hope this is sufficient for anyone that needs to run syncdb manually or via a script that they will now have this --skip-migrations flag to get the behavior they desire.