Date: Mon, 24 Apr 2017 03:13:53 -0400 From: David Mehler <dave.mehler@gmail.com> To: freebsd-questions <freebsd-questions@freebsd.org> Subject: Can not add foreign key constraint Message-ID: <CAPORhP4Y7JUn%2BZX6Dtju9KVdqLW11Mv0AddUTL%2BNhQMDOVf5og@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello, Not sure if this is a FreeBSD issue specific with the Mysql port I'm trying to add a table to an existing database. I'm wanting it to get one of it's fields from an already existing table. I've done this before in this database. This works: CREATE TABLE `virtual_users` ( `id` int(11) NOT NULL auto_increment, `domain_id` int(11) NOT NULL, `user` varchar(40) NOT NULL, `password` varchar(128) NOT NULL, `quota` bigint(20) NOT NULL DEFAULT 256, `quota_messages` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`), FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; This does not: CREATE TABLE IF NOT EXISTS `lastauth` ( `user` varchar(40) NOT NULL, `remote_ip` varchar(18) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`user`), FOREIGN KEY (user) REFERENCES virtual_users(user) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Can anyone spot the situation? Thanks. Dave.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPORhP4Y7JUn%2BZX6Dtju9KVdqLW11Mv0AddUTL%2BNhQMDOVf5og>