I'm using Django 1.6 + MySQL. My model has a custom_user class that extends AbstractUser.
class CustomUser(AbstractUser):
dob = models.DateField()
class Meta:
db_table = 'custom_user'
I want to delete the database with ./manage.py sqlclear | ./manage.py dbshell
(as mentioned here)
The output of sqlclear is
BEGIN;
DROP TABLE `design`;
DROP TABLE `company`;
ALTER TABLE `custom_user_user_permissions` DROP FOREIGN KEY `customuser_id_refs_id_da27cb33`;
ALTER TABLE `custom_user_groups` DROP FOREIGN KEY `customuser_id_refs_id_d24c897a`;
DROP TABLE `custom_user`;
DROP TABLE `custom_user_user_permissions`;
DROP TABLE `custom_user_groups`;
DROP TABLE `book`;
DROP TABLE `author`;
COMMIT;
This fails with error :
ERROR 1217 (23000) at line 6: Cannot delete or update a parent row: a foreign key constraint fails
The first 2 tables (design & company) get deleted. If I run the command again, I get
ERROR 1091 (42000) at line 2: Can't DROP 'customuser_id_refs_id_da27cb33'; check that column/key exists