Warning at enabling module - Can't create tables
| Project: | MailServer |
| Version: | 5.x-1.0-beta |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | jmary |
| Status: | patch (to be ported) |
* user warning: Can't create table './example/mail_mailserver_virtual_users.frm' (errno: 150) query: CREATE TABLE mail_mailserver_virtual_users ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, domain_id INT(11) NOT NULL, user VARCHAR(40) NOT NULL, password VARCHAR(32) NOT NULL, CONSTRAINT UNIQUE_EMAIL UNIQUE (domain_id, user), FOREIGN KEY (domain_id) REFERENCES mailserver_virtual_domains(id) ON DELETE CASCADE ) ENGINE = InnoDB /*!40100 DEFAULT CHARACTER SET utf8 */; in /var/www/vhosts/example.com/includes/database.mysql.inc on line 172.
* user warning: Can't create table './example/mail_mailserver_virtual_aliases.frm' (errno: 150) query: CREATE TABLE mail_mailserver_virtual_aliases ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, domain_id INT(11) NOT NULL, source VARCHAR(40) NOT NULL, destination VARCHAR(80) NOT NULL, FOREIGN KEY (domain_id) REFERENCES mailserver_virtual_domains(id) ON DELETE CASCADE ) ENGINE = InnoDB /*!40100 DEFAULT CHARACTER SET utf8 */; in /var/www/vhosts/example.com/includes/database.mysql.inc on line 172.

#1
This is a mistake in the SQL request : The prefix mail_ which I set up at installing drupal is not considered in the reference of the foreign key.
It should be :
CREATE TABLE mail_mailserver_virtual_users ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, domain_id INT(11) NOT NULL, user VARCHAR(40) NOT NULL, password VARCHAR(32) NOT NULL, CONSTRAINT UNIQUE_EMAIL UNIQUE (domain_id, user), FOREIGN KEY (domain_id) REFERENCES mail_mailserver_virtual_domains(id) ON DELETE CASCADE ) ENGINE = InnoDB
and
CREATE TABLE mail_mailserver_virtual_aliases ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, domain_id INT(11) NOT NULL, source VARCHAR(40) NOT NULL, destination VARCHAR(80) NOT NULL, FOREIGN KEY (domain_id) REFERENCES mail_mailserver_virtual_domains(id) ON DELETE CASCADE ) ENGINE = InnoDB
#2
The answer above doesn't fix the issue :
The system then expect to find the tables without the prefix mail_ when adding a domain.
#3
This patch solves the problem of the non inserted prefix when referencing the table :
prefix_mailserver_virtual_domains
at creating the tables :
mail_mailserver_virtual_users and mail_mailserver_virtual_aliases.
========
This is solving one issue, we have another one then when we want to add a domain.