django-orm数据迁移存在的问题

迁移时字段默认值

django-orm数据迁移存在的问题
最好选择2显性显示数据修改情况,防止他人接手时存在黑匣子

数据库迁移文件混乱

django-orm数据迁移存在的问题

执行迁移文件的记录会存在数据库中(表django_migrations)

mysql> select  *  from django_migrations;
+----+--------------+------------------------------------------+----------------
------------+
| id | app          | name                                     | applied
            |
+----+--------------+------------------------------------------+----------------
------------+
|  1 | contenttypes | 0001_initial                             | 2021-08-07 01:0
8:41.657489 |
|  2 | auth         | 0001_initial                             | 2021-08-07 01:0
8:44.118630 |
|  3 | admin        | 0001_initial                             | 2021-08-07 01:0
8:53.170148 |
|  4 | admin        | 0002_logentry_remove_auto_add            | 2021-08-07 01:0
8:55.290269 |
|  5 | admin        | 0003_logentry_add_action_flag_choices    | 2021-08-07 01:0
8:55.369274 |
|  6 | contenttypes | 0002_remove_content_type_name            | 2021-08-07 01:0
8:56.887360 |
|  7 | auth         | 0002_alter_permission_name_max_length    | 2021-08-07 01:0
8:57.796412 |
|  8 | auth         | 0003_alter_user_email_max_length         | 2021-08-07 01:0
8:58.694464 |
|  9 | auth         | 0004_alter_user_username_opts            | 2021-08-07 01:0
8:58.755467 |
| 10 | auth         | 0005_alter_user_last_login_null          | 2021-08-07 01:0
8:59.591515 |
| 11 | auth         | 0006_require_contenttypes_0002           | 2021-08-07 01:0
8:59.635518 |
| 12 | auth         | 0007_alter_validators_add_error_messages | 2021-08-07 01:0
8:59.707522 |
| 13 | auth         | 0008_alter_user_username_max_length      | 2021-08-07 01:0
9:00.897590 |
| 14 | auth         | 0009_alter_user_last_name_max_length     | 2021-08-07 01:0
9:02.071657 |
| 15 | auth         | 0010_alter_group_name_max_length         | 2021-08-07 01:0
9:03.111716 |
| 16 | auth         | 0011_update_proxy_permissions            | 2021-08-07 01:0
9:03.194721 |
| 17 | bookstore    | 0001_initial                             | 2021-08-07 01:0
9:03.689749 |
| 18 | sessions     | 0001_initial                             | 2021-08-07 01:0
9:04.109773 |
| 19 | bookstore    | 0002_author                              | 2021-08-07 01:4
1:16.223284 |
| 20 | bookstore    | 0003_auto_20210807_1002                  | 2021-08-07 02:0
2:22.986739 |
| 21 | bookstore    | 0004_auto_20210807_1726                  | 2021-08-07 09:2
6:42.126554 |
+----+--------------+------------------------------------------+----------------
------------+
21 rows in set (0.00 sec)

mysql> select  *  from django_migrations\G:;
*************************** 1. row ***************************
     id: 1
    app: contenttypes
   name: 0001_initial
applied: 2021-08-07 01:08:41.657489
*************************** 2. row ***************************
     id: 2
    app: auth
   name: 0001_initial
applied: 2021-08-07 01:08:44.118630
*************************** 3. row ***************************
     id: 3
    app: admin
   name: 0001_initial
applied: 2021-08-07 01:08:53.170148
*************************** 4. row ***************************
     id: 4
    app: admin
   name: 0002_logentry_remove_auto_add
applied: 2021-08-07 01:08:55.290269
*************************** 5. row ***************************
     id: 5
    app: admin
   name: 0003_logentry_add_action_flag_choices
applied: 2021-08-07 01:08:55.369274
*************************** 6. row ***************************
     id: 6
    app: contenttypes
   name: 0002_remove_content_type_name
applied: 2021-08-07 01:08:56.887360
*************************** 7. row ***************************
     id: 7
    app: auth
   name: 0002_alter_permission_name_max_length
applied: 2021-08-07 01:08:57.796412
*************************** 8. row ***************************
     id: 8
    app: auth
   name: 0003_alter_user_email_max_length
applied: 2021-08-07 01:08:58.694464
*************************** 9. row ***************************
     id: 9
    app: auth
   name: 0004_alter_user_username_opts
applied: 2021-08-07 01:08:58.755467
*************************** 10. row ***************************
     id: 10
    app: auth
   name: 0005_alter_user_last_login_null
applied: 2021-08-07 01:08:59.591515
*************************** 11. row ***************************
     id: 11
    app: auth
   name: 0006_require_contenttypes_0002
applied: 2021-08-07 01:08:59.635518
*************************** 12. row ***************************
     id: 12
    app: auth
   name: 0007_alter_validators_add_error_messages
applied: 2021-08-07 01:08:59.707522
*************************** 13. row ***************************
     id: 13
    app: auth
   name: 0008_alter_user_username_max_length
applied: 2021-08-07 01:09:00.897590
*************************** 14. row ***************************
     id: 14
    app: auth
   name: 0009_alter_user_last_name_max_length
applied: 2021-08-07 01:09:02.071657
*************************** 15. row ***************************
     id: 15
    app: auth
   name: 0010_alter_group_name_max_length
applied: 2021-08-07 01:09:03.111716
*************************** 16. row ***************************
     id: 16
    app: auth
   name: 0011_update_proxy_permissions
applied: 2021-08-07 01:09:03.194721
*************************** 17. row ***************************
     id: 17
    app: bookstore
   name: 0001_initial
applied: 2021-08-07 01:09:03.689749
*************************** 18. row ***************************
     id: 18
    app: sessions
   name: 0001_initial
applied: 2021-08-07 01:09:04.109773
*************************** 19. row ***************************
     id: 19
    app: bookstore
   name: 0002_author
applied: 2021-08-07 01:41:16.223284
*************************** 20. row ***************************
     id: 20
    app: bookstore
   name: 0003_auto_20210807_1002
applied: 2021-08-07 02:02:22.986739
*************************** 21. row ***************************
     id: 21
    app: bookstore
   name: 0004_auto_20210807_1726
applied: 2021-08-07 09:26:42.126554
21 rows in set (0.00 sec)

django-orm数据迁移存在的问题

上一篇:Sanic十六:Sanic + 异步orm之SQLAlchemy


下一篇:SQLAlchemy 与 MySQL数据库事务隔离级别(Transaction Isolation Level)