英文:
Django - INTEGRITY ERROR on column that no longer exists
问题
我遇到了这个错误:
IntegrityError at /register/
在列 "total_daily_mission_progress" 中的空值违反了非空约束
详细信息:失败的行包含 (363, 0, 374, free, 0, null, unranked, 0, , odifj@gmail.com, 0, f, [], 0, {}, {}, t, null, null, null, null, null, {}, null, null, No phone number set, This user has not set a description yet., /static/images/profilepictures/defaultavatar.png, {}, {}, {}, {}, {}, 0)。
然而,total_daily_mission_progress
列在我的 UserDetail
模型中已经不存在了。我一段时间前删除了它并进行了迁移。然而,每次我尝试创建一个新的 UserDetail
模型时都会出现这个问题。
为什么会发生这种情况?我在我的代码中没有 total_daily_mission_progress
,我该如何修复它?
编辑:
这是我运行 python3 manage.py showmigrations --verbosity 2
后的输出。
英文:
I am getting this error:
IntegrityError at /register/
null value in column "total_daily_mission_progress" violates not-null constraint
DETAIL: Failing row contains (363, 0, 374, free, 0, null, unranked, 0, , odifj@gmail.com, 0, f, [], 0, {}, {}, t, null, null, null, null, null, {}, null, null, No phone number set, This user has not set a description yet., /static/images/profilepictures/defaultavatar.png, {}, {}, {}, {}, {}, 0).
However, the column total_daily_mission_progress
no longer exists in my UserDetail
model. I deleted it a while ago and migrated. However, this issue comes up every time I try to create a new UserDetail model.
Why is this occuring? I don't have the total_daily_mission_progress
anywhere in my code. And how can I fix it?
EDIT:
Here is my output after running python3 manage.py showmigrations --verbosity 2
[X] 0001_initial (applied at 2022-12-29 19:39:10)
[X] 0002_logentry_remove_auto_add (applied at 2022-12-29 19:39:10)
[X] 0003_logentry_add_action_flag_choices (applied at 2022-12-29 19:39:10)
auth
[X] 0001_initial (applied at 2022-12-29 19:39:09)
[X] 0002_alter_permission_name_max_length (applied at 2022-12-29 19:39:11)
[X] 0003_alter_user_email_max_length (applied at 2022-12-29 19:39:11)
[X] 0004_alter_user_username_opts (applied at 2022-12-29 19:39:11)
[X] 0005_alter_user_last_login_null (applied at 2022-12-29 19:39:12)
[X] 0006_require_contenttypes_0002 (applied at 2022-12-29 19:39:12)
[X] 0007_alter_validators_add_error_messages (applied at 2022-12-29 19:39:12)
[X] 0008_alter_user_username_max_length (applied at 2022-12-29 19:39:12)
[X] 0009_alter_user_last_name_max_length (applied at 2022-12-29 19:39:13)
[X] 0010_alter_group_name_max_length (applied at 2022-12-29 19:39:13)
[X] 0011_update_proxy_permissions (applied at 2022-12-29 19:39:13)
[X] 0012_alter_user_first_name_max_length (applied at 2022-12-29 19:39:13)
codera_main
[X] 0001_initial (applied at 2022-12-29 19:39:14)
[X] 0002_achievement_reward_alter_achievement_rarity (applied at 2022-12-29 19:39:15)
[X] 0003_achievement_num (applied at 2022-12-29 19:39:15)
[X] 0004_alter_achievement_name_alter_achievement_num (applied at 2022-12-29 19:39:15)
[X] 0005_alter_achievement_description_alter_achievement_name (applied at 2022-12-29 19:39:16)
[X] 0006_userdetail (applied at 2022-12-29 19:39:17)
[X] 0007_userdetail_skilllevel (applied at 2022-12-29 19:39:17)
[X] 0008_userdetail_plan (applied at 2022-12-29 19:39:17)
[X] 0009_userdetail_friends_alter_userdetail_skilllevel (applied at 2022-12-29 19:39:17)
[X] 0010_alter_userdetail_friends (applied at 2022-12-29 19:39:18)
[X] 0011_alter_userdetail_friends (applied at 2022-12-29 19:39:18)
[X] 0012_alter_userdetail_friends (applied at 2022-12-29 19:39:18)
[X] 0013_userstat (applied at 2022-12-29 19:39:19)
[X] 0014_usercode (applied at 2022-12-29 19:39:19)
[X] 0015_userreward (applied at 2022-12-29 19:39:20)
[X] 0016_remove_userstat_ribbons_remove_userstat_shards_and_more (applied at 2022-12-29 19:39:20)
[X] 0017_alter_userdetail_totallearningtime (applied at 2022-12-29 19:39:21)
[X] 0018_alter_userdetail_totallearningtime (applied at 2022-12-29 19:39:21)
[X] 0019_alter_userdetail_totallearningtime (applied at 2022-12-29 19:39:22)
[X] 0020_alter_userdetail_totallearningtime (applied at 2022-12-29 19:39:22)
[X] 0021_userstat_last_login (applied at 2022-12-29 19:39:23)
[X] 0022_userstat_monthly_streaks (applied at 2022-12-29 19:39:23)
[X] 0023_userdetail_user_spent (applied at 2022-12-29 19:39:23)
[X] 0024_remove_userdetail_user_spent_and_more (applied at 2022-12-29 19:39:24)
[X] 0025_alter_userdetail_totallearningtime (applied at 2022-12-29 19:39:24)
[X] 0026_alter_usercode_levelscompleted (applied at 2022-12-29 19:39:25)
[X] 0027_remove_achievement_rarity_remove_achievement_reward_and_more (applied at 2022-12-29 19:39:25)
[X] 0028_achievement_achive_date (applied at 2022-12-29 19:39:25)
[X] 0029_alter_achievement_num (applied at 2022-12-29 19:39:26)
[X] 0030_rename_name_achievement_title (applied at 2022-12-29 19:39:26)
[X] 0031_delete_userreward (applied at 2022-12-29 19:39:26)
[X] 0032_userdetail_profilepicture (applied at 2022-12-29 19:39:27)
[X] 0033_alter_userdetail_profilepicture (applied at 2022-12-29 19:39:27)
[X] 0034_alter_userdetail_profilepicture (applied at 2022-12-29 19:39:27)
[X] 0035_alter_userdetail_profilepicture (applied at 2022-12-29 19:39:27)
[X] 0036_userstat_badges (applied at 2022-12-29 19:39:28)
[X] 0037_remove_userstat_badges_userreward (applied at 2022-12-29 19:39:28)
[X] 0038_remove_userdetail_profilepicture (applied at 2023-01-16 15:38:38)
[X] 0039_remove_userdetail_friends (applied at 2023-01-16 15:40:34)
[X] 0040_emailverified (applied at 2023-02-18 02:18:32)
[X] 0041_remove_usercode_levelscompleted_and_more (applied at 2023-02-18 02:18:33)
[X] 0042_userdetail_isverified (applied at 2023-02-18 02:18:33)
[X] 0043_remove_usercode_user_remove_userreward_user_and_more (applied at 2023-02-18 02:40:26)
[X] 0044_alter_userdetail_levelscompleted (applied at 2023-02-18 02:40:28)
[X] 0045_userdetail_xp_alter_userdetail_league (applied at 2023-02-18 02:40:28)
[X] 0046_avatar (applied at 2023-02-18 02:40:29)
[X] 0047_alter_avatar_moves_unlocked (applied at 2023-02-18 02:40:29)
[X] 0048_alter_avatar_moves_unlocked (applied at 2023-02-18 02:40:29)
[X] 0049_userdetail_yesturday_diamonds (applied at 2023-02-18 02:40:29)
[X] 0050_remove_userdetail_yesturday_diamonds_and_more (applied at 2023-02-18 02:40:30)
[X] 0051_alter_userdetail_dimaond_progress (applied at 2023-02-18 02:40:30)
[X] 0052_rename_dimaond_progress_userdetail_diamond_progress (applied at 2023-02-18 02:40:30)
[X] 0053_userdetail_medal_progress (applied at 2023-02-18 02:40:30)
[X] 0054_alter_userdetail_totallearningtime_badge (applied at 2023-02-18 02:40:31)
[X] 0055_badge_image (applied at 2023-02-18 02:40:32)
[X] 0056_badge_popup_image (applied at 2023-02-18 02:40:32)
[X] 0057_alter_badge_badge_date_and_more (applied at 2023-02-18 02:40:32)
[X] 0058_alter_badge_badge_date (applied at 2023-02-18 02:40:33)
[X] 0059_alter_badge_badge_date (applied at 2023-02-18 02:40:33)
[X] 0060_alter_achievement_user_alter_badge_user (applied at 2023-02-18 02:40:34)
[X] 0061_userdetail_iscurrentlyactive (applied at 2023-02-18 02:40:34)
[X] 0062_avatar_accuracy_avatar_speed_alter_avatar_character_and_more (applied at 2023-02-18 02:40:35)
[X] 0063_avatar_rank (applied at 2023-02-18 02:40:35)
[X] 0064_alter_avatar_moves_unlocked_alter_avatar_rank (applied at 2023-02-18 02:40:35)
[X] 0065_alter_avatar_moves_unlocked (applied at 2023-02-18 02:40:36)
[X] 0066_avatar_strenght (applied at 2023-02-18 02:40:36)
[X] 0067_rename_strenght_avatar_strength (applied at 2023-02-18 02:40:37)
[X] 0068_userdetail_plan_purchase_date (applied at 2023-02-18 02:40:37)
[X] 0069_userdetail_checkout_id (applied at 2023-02-18 02:40:37)
[X] 0070_alter_avatar_accuracy_alter_avatar_energy_and_more (applied at 2023-02-20 17:13:05)
[X] 0071_guideemail (applied at 2023-02-22 23:52:59)
[X] 0072_dailymission_userdetail_todays_daily_mission_and_more (applied at 2023-04-20 22:14:25)
[X] 0074_alter_userdetail_totallearningtime (applied at 2023-04-24 13:54:24)
[X] 0075_chest (applied at 2023-04-24 17:10:00)
[X] 0076_userdetail_friends_list (applied at 2023-05-01 14:30:12)
[X] 0077_friendrequest (applied at 2023-05-01 14:37:47)
[X] 0078_friendrequest_date_sent (applied at 2023-05-01 22:54:00)
[X] 0079_alter_friendrequest_date_sent (applied at 2023-05-01 23:00:54)
[X] 0080_alter_friendrequest_date_sent (applied at 2023-05-02 01:07:36)
[X] 0081_alter_userdetail_friends_list (applied at 2023-05-02 23:57:12)
[X] 0082_remove_userdetail_friends_list (applied at 2023-05-02 23:59:09)
[X] 0083_userdetail_friends_list (applied at 2023-05-02 23:59:27)
[X] 0084_userdetail_first_name_userdetail_last_name_and_more (applied at 2023-05-09 20:39:01)
[X] 0085_userdetail_description (applied at 2023-05-09 20:43:14)
[X] 0086_userdetail_profile_picture (applied at 2023-05-09 21:41:22)
[X] 0087_alter_userdetail_phone_number (applied at 2023-05-09 22:48:31)
[X] 0088_alter_userdetail_profile_picture (applied at 2023-05-09 22:59:01)
[X] 0089_remove_userdetail_profile_picture (applied at 2023-05-09 23:00:03)
[X] 0090_userdetail_profile_picture (applied at 2023-05-09 23:00:13)
[X] 0091_alter_userdetail_profile_picture (applied at 2023-05-09 23:08:33)
[X] 0092_remove_userdetail_profile_picture (applied at 2023-05-09 23:09:17)
[X] 0093_userdetail_profile_picture (applied at 2023-05-09 23:09:55)
[X] 0094_remove_userdetail_profile_picture (applied at 2023-05-10 00:31:07)
[X] 0095_userdetail_profile_picture (applied at 2023-05-10 00:31:20)
[X] 0096_remove_userdetail_profile_picture (applied at 2023-05-10 00:34:04)
[X] 0097_userdetail_profile_picture (applied at 2023-05-10 00:34:17)
[X] 0098_remove_userdetail_profile_picture (applied at 2023-05-10 00:37:46)
[X] 0099_userdetail_profile_picture (applied at 2023-05-10 00:41:59)
[X] 0100_alter_userdetail_profile_picture (applied at 2023-05-10 00:46:03)
[X] 0101_alter_userdetail_profile_picture (applied at 2023-05-10 00:48:49)
[X] 0102_remove_userdetail_profile_picture (applied at 2023-05-10 00:49:22)
[X] 0103_userdetail_profile_picture (applied at 2023-05-10 00:50:02)
[X] 0104_alter_userdetail_profile_picture (applied at 2023-05-10 14:32:59)
[X] 0105_alter_userdetail_league (applied at 2023-05-21 23:31:23)
[X] 0106_userdetail_xp_progress_and_more (applied at 2023-05-28 23:28:41)
[X] 0107_remove_userdetail_todays_daily_mission_completed_and_more (applied at 2023-05-29 16:14:45)
[X] 0108_remove_userdetail_todays_daily_mission_and_more (applied at 2023-05-29 16:14:45)
[X] 0109_userdetail_todaysdailymission_and_more (applied at 2023-06-01 14:39:33)
[X] 0110_rename_todaysdailymissioncompelted_userdetail_todaysdailymissioncompleted (applied at 2023-06-01 14:39:33)
[X] 0111_mainmission_alter_dailymission_num_and_more (applied at 2023-06-01 14:39:34)
contenttypes
[X] 0001_initial (applied at 2022-12-29 19:39:05)
[X] 0002_remove_content_type_name (applied at 2022-12-29 19:39:11)
sessions
[X] 0001_initial (applied at 2022-12-29 19:39:29)
答案1
得分: 0
使用了python3 manage.py dbshell
,并运行以下命令:
ALTER TABLE_NAME FROM USERMODAL
英文:
Ended up figuring it out, ended up using python3 manage.py dbshell
and runnning the following command:
ALTER TABLE_NAME FROM USERMODAL
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论