All pastes #2065914 Raw Edit

Stuff

public text v1 · immutable
#2065914 ·published 2011-05-20 17:43 UTC
rendered paste body
CREATE TABLE `registration_registrationprofile` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `activation_key` varchar(40) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id` (`user_id`),
  CONSTRAINT `user_id_refs_id_313280c4` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

CREATE TABLE `auth_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL DEFAULT '',
  `first_name` varchar(30) NOT NULL DEFAULT '',
  `last_name` varchar(30) NOT NULL DEFAULT '',
  `email` varchar(75) NOT NULL DEFAULT '',
  `password` varchar(128) NOT NULL DEFAULT '',
  `is_staff` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '0',
  `is_superuser` tinyint(1) NOT NULL DEFAULT '0',
  `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_joined` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM AUTO_INCREMENT=5119 DEFAULT CHARSET=utf8;

mysql> INSERT INTO registration_registrationprofile (user_id, activation_key) VALUES (5116, '038c6af9f1ac5329d95116f32fd4c0e21eb5bc17');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`pydev`.`registration_registrationprofile`, CONSTRAINT `user_id_refs_id_313280c4` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))
mysql> select id, username from auth_user where id = 5116;
+------+----------+
| id   | username |
+------+----------+
| 5116 | grad     |
+------+----------+
1 row in set (0.00 sec)