zoukankan      html  css  js  c++  java
  • django-orm数据迁移存在的问题

    迁移时字段默认值


    最好选择2显性显示数据修改情况,防止他人接手时存在黑匣子

    数据库迁移文件混乱

    执行迁移文件的记录会存在数据库中(表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_migrationsG:;
    *************************** 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)
    

  • 相关阅读:
    python基础易错题
    经典案例题2
    经典案例题1
    Http和Https的区别
    爬虫过程中需要注意的问题
    [转]项目规模估计方法介绍
    [转]23种设计模式总结
    [转]分布式session的几种实现方式
    [转]Redis哨兵模式(sentinel)学习总结及部署记录(主从复制、读写分离、主从切换)
    [转]【Linux】Linux 目录结构
  • 原文地址:https://www.cnblogs.com/yescarf/p/15112596.html
Copyright © 2011-2022 走看看