What is your favorite solution for managing databa

2019-01-08 07:29发布

I quite like Rails' database migration management system. It is not 100% perfect, but it does the trick. Django does not ship with such a database migration system (yet?) but there are a number of open source projects to do just that, such as django-evolution and south for example.

So I am wondering, what database migration management solution for django do you prefer? (one option per answer please)

8条回答
Rolldiameter
2楼-- · 2019-01-08 08:06

If you are using SQLAlchemy as your ORM then the de facto standard is Alembic.

Another alternative that haven't been mentioned is yoyo-migrations.

查看更多
3楼-- · 2019-01-08 08:08

Just to note that since 2009, pretty much every project mentioned here other than South is dead. South is the de facto standard, for better or worse.

查看更多
放荡不羁爱自由
4楼-- · 2019-01-08 08:09

I like django-evolution:

pros:

  • clean design
  • no SQL needed
  • flexible
  • trivial to install
  • easy to use

cons:

  • migrations are not fixed in the codebase
  • a risk exists of accidently running a migration twice
查看更多
Lonely孤独者°
5楼-- · 2019-01-08 08:10

I've been using simple-db-migrate

Pros:

  • it allows me to rollback the migrations (IDK if other do this too).
  • integrates with manage.py
  • everyone that knows SQL can create a migration
  • it doesn't run a migration twice: the application writes the migration information(timestamp, query, etc.) on a table

Cons:

  • if you add a migration with a lower timestamp than the latest migration installed, this migration doesn't run
  • Only MySQL is supported
查看更多
Fickle 薄情
6楼-- · 2019-01-08 08:16

I've been using South, but Migratory looks promising as well.

查看更多
Emotional °昔
7楼-- · 2019-01-08 08:16

We use Django at work, and we've been using dmigrations. While it has its quirks, it's been useful so far. Some features:

  • It uses a table in the database to keep track of which migrations have been applied.
  • Because it knows which ones have been applied, you can migrate up and back down.
  • It integrates with manage.py as a command.
  • The individual migration scripts are Python, but if your migration logic is pure SQL, dmigrations makes it easy to just can the SQL and have it executed.

One problem is that it only currently supports MySQL. However, one of our guys make a local hack to it to support PostgreSQL, which we use. As I recall, the hack wasn't all that extensive, so it shouldn't be terribly difficult to hack it up to support other RDBMSs.

查看更多
登录 后发表回答