From owner-freebsd-questions@freebsd.org Mon Apr 24 07:13:55 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B83D7D4D79E for ; Mon, 24 Apr 2017 07:13:55 +0000 (UTC) (envelope-from dave.mehler@gmail.com) Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 481AA879 for ; Mon, 24 Apr 2017 07:13:55 +0000 (UTC) (envelope-from dave.mehler@gmail.com) Received: by mail-wm0-x22d.google.com with SMTP id w64so53849154wma.0 for ; Mon, 24 Apr 2017 00:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZbUk27VnK2S/gV73Y1IivRsMwjGEH4bzlfSaUZJwutM=; b=O/lSbOWW0kGLS4u6ChQgbv21UKugA2BgdQp4NaUT0hLz+Su7cFQZn5ZLMQBzeWUTdN 9mLLto/2XutgUtNw0t8R3TK/95tXjp71vexPYZkCiK6czNhtTxGI+jDMLOvLzP1B9kPZ iuPLVEktCXF6KN1LGQZ6WRqjKnj/myiUafOLmycTcObGEMHoOJPRHeDk32nn/n2F+KKn K1xloXd6MElUx0lB/PsM23Xp4ly9SqnrpeTbqZaNwUgWm1zcpZzyrTIqdMNrQBfeZIdF ztHzq3GUsjf+VtkMZObHf0Fg3EdReV+3/j4tC0nteYS883BA5hgLwL+yXgYT5pNgk0y7 8gDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZbUk27VnK2S/gV73Y1IivRsMwjGEH4bzlfSaUZJwutM=; b=gT6SNikkLmtNe6+DkzTNV0CUzNa2Duo6WVw55GAey/NTQNLRYbh8tGtwq0hucNzCMg IFzyCId9jeJjIChaSqoeXEOgL8o0+/6GMIWyTX/AQp9JZ640OFNuPkMyV9rXYu5mbMbc 1MqC0wLM9E4KUxI7sT9uhqLx0GLITxwT/2NxsLEvm+eK+lRYfQGOGvAtwEwAn48Y7zty B//Lp2Kw0Z10FwWDAPt4nR+XAeoZxalhxYP0zenrHBPkaMAKLkdQEouu3z4E16JpHJwD QowqQicSksdMnKCz7CILLOgKWxXhjSN9gQfKOSql2rLrW6pxtMiTv+cdM7wZS1IrvIEj xd6A== X-Gm-Message-State: AN3rC/7fVflPKMsnye1iZSdaX1OlHTGN38oI6vwKZbAEb03zwC71jAFO /v2fqhz80aIzlSnhI94Li1Sm9T7EQQ== X-Received: by 10.28.151.213 with SMTP id z204mr8664321wmd.48.1493018033537; Mon, 24 Apr 2017 00:13:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.136.51 with HTTP; Mon, 24 Apr 2017 00:13:53 -0700 (PDT) From: David Mehler Date: Mon, 24 Apr 2017 03:13:53 -0400 Message-ID: Subject: Can not add foreign key constraint To: freebsd-questions Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Apr 2017 07:13:55 -0000 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.