Django中model使用迁移(migrate)部分数据库会遇到的坑
来源:互联网 发布:浙江移动网络运营岗位 编辑:程序博客网 时间:2024/06/05 02:49
Django中model使用迁移(migrate)部分数据库会遇到的坑
PostgreSQL
PostgreSQL is the most capable of all the databases here in terms of schema support; the only caveat is that adding columns with default values will cause a full rewrite of the table, for a time proportional to its size.For this reason, it’s recommended you always create new columns with null=True, as this way they will be added immediately.
MySQL
MySQL lacks support for transactions around schema alteration operations, meaning that if a migration fails to apply you will have to manually unpick the changes in order to try again (it’s impossible to roll back to an earlier point).In addition, MySQL will fully rewrite tables for almost every schema operation and generally takes a time proportional to the number of rows in the table to add or remove columns. On slower hardware this can be worse than a minute per million rows - adding a few columns to a table with just a few million rows could lock your site up for over ten minutes.
Finally, MySQL has reasonably small limits on name lengths for columns, tables and indexes, as well as a limit on the combined size of all columns an index covers. This means that indexes that are possible on other backends will fail to be created under MySQL.
SQLite
SQLite has very little built-in schema alteration support, and so Django attempts to emulate it by:Creating a new table with the new schema
Copying the data across
删除旧表
Renaming the new table to match the original name
This process generally works well, but it can be slow and occasionally buggy. It is not recommended that you run and migrate SQLite in a production environment unless you are very aware of the risks and its limitations; the support Django ships with is designed to allow developers to use SQLite on their local machines to develop less complex Django projects without the need for a full database.
0 0
- Django中model使用迁移(migrate)部分数据库会遇到的坑
- python使用flask-migrate迁移数据库时遇到的问题
- rails 迁移migrate model对应的数据库字段类型
- django 数据库迁移(migrate)应该知道的一些事
- Laravel数据库迁移文件migrate使用约定
- 使用 Flask-Migrate 实现数据库迁移
- Yii2之数据库迁移(Migrate)
- yii2 migrate 数据库迁移
- Flask-Migrate数据库迁移
- 做Flask-Migrate数据库迁移 遇到了报错
- 数据库(三)为Python shell添加新的功能和使用Flask-Migrate实现数据库迁移
- django数据库migrate失败的解决方法
- 在Django中使用数据库遇到的问题
- 解决django项目迁移过程中遇到的问题。
- Flask-Migrate实现数据库迁移
- Django: model与makemigrations、migrate、syncdb详解
- django用migrate在已有数据库中新建表
- django使用model创建数据库表使用的字段
- php文件操作
- 用JAVA实现 hex字符串转出字符串
- iOS 【上架问题】ERROR ITMS-90086
- Matlab 集群计算平台搭建
- html浮动,相对,绝对布局
- Django中model使用迁移(migrate)部分数据库会遇到的坑
- 数据库范式实例
- JavaWeb伪静态
- 性能分析框架和性能监控平台
- selector和shape混合使用 开发技巧(一)
- Linux下NFS、FTP使用讲解
- solr基本操作代码示例
- “Count Primes” and "Range Sum Query - Immutable"
- C++面向对象的程序设计——继承