南。迁移整个数据库
如何一步迁移整个数据库? South 的 startmigration 命令只能与单个应用程序一起使用
how can i migrate entiry db at one step? south`s startmigration command can work only with single application
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想创建迁移,
manage.py startmigration
已弃用(请参阅manage.py help startmigration
),您应该使用manage.py schemamigration
(如中所述docs),并且您绝对应该在每个应用程序上单独执行此操作。如果您想运行迁移(换句话说,实际更改数据库,我猜就是这种情况),则命令是
manage.py migrate
如果不带任何参数运行,则会将所有应用迁移到可用的最新迁移。我的部署脚本只有
manage.py migrate
,无论有多少应用程序需要运行新的迁移,它都可以正常工作,无需手动干预。If you want to create a migration,
manage.py startmigration
is deprecated (seemanage.py help startmigration
), you should be usingmanage.py schemamigration
(as described in the docs), and you should definitely be doing this individually on each app.If you want to run migrations (in other words do the actual altering of the database, which I'm guessing is the case), The command for that is
manage.py migrate
which, if run without any arguments, will migrate all of your apps to the latest migration available.My deployment script just has
manage.py migrate
, and it works fine without manual intervention, no matter how many apps have new migrations that need to be run.即使使用原始 SQL,您也无法通过一步迁移整个数据库,因为您需要对每个表进行查询。但是,您可以为所有应用程序创建迁移,然后立即运行它们。这是最接近一步迁移的事情。
Even with raw SQL, you wont be able to migrate an entire database in a single step as you need a query per table. You can however, create migrations for all apps, and then run them all at once. That's the closest thing you'll come to a one step migration.