Create.vmail.sql: Difference between revisions

From SaruWiki
Jump to navigation Jump to search
m (limited vmal_admin rights)
(Updated to MySQL5.0, InnoDB and relational tables)
Line 14: Line 14:
         'vmail_admin',
         'vmail_admin',
         'Y'
         'Y'
  );  
  );
   
   
  -- Make sure that priviliges are reloaded.
  -- Make sure that priviliges are reloaded.
  FLUSH PRIVILEGES;
  FLUSH PRIVILEGES;
   
   
  -- we're assuming the database does not exist yet
  -- You should drop a pre-existing "vmail"
-- database manually to avoid CREATE errors.
  CREATE DATABASE vmail;
  CREATE DATABASE vmail;
   
   
  USE vmail;
  USE vmail;
   
   
  CREATE TABLE domains (
  CREATE TABLE virtual_domains (
     domain        VARCHAR(50) NOT NULL,
     id            INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    vdomain      VARCHAR(50) NOT NULL
    ) ENGINE = InnoDB;
   
   
     PRIMARY KEY (domain) ) TYPE=MyISAM;
CREATE TABLE relaydomains (
    id            INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    relaydomain  VARCHAR(80) NOT NULL,
    transport    VARCHAR(80) NOT NULL
    ) ENGINE = InnoDB;
CREATE TABLE virtual_users (
     id            INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    domain_id    INT(11) NOT NULL,
    user          VARCHAR(40) NOT NULL,
    passwd        VARCHAR(32) NOT NULL
    ) ENGINE = InnoDB;
   
   
  CREATE TABLE forwardings (
  CREATE TABLE virtual_aliases (
    id            INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    domain_id    INT(11) NOT NULL,
     source        VARCHAR(80) NOT NULL,
     source        VARCHAR(80) NOT NULL,
     destination  TEXT NOT NULL,
     destination  VARCHAR(80) NOT NULL,
     FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
    PRIMARY KEY (source) ) TYPE=MyISAM;
     ) ENGINE = InnoDB;
CREATE TABLE users (
    emailaddr    VARCHAR(80) NOT NULL,
     passwd        VARCHAR(30) NOT NULL,
    PRIMARY KEY (emailaddr) ) TYPE=MyISAM;
CREATE TABLE relaydomains (
    rdomain      VARCHAR(80) NOT NULL,
     transport    VARCHAR(80) NOT NULL,
    PRIMARY KEY (rdomain) ) TYPE=MyISAM;
   
   
  FLUSH PRIVILEGES;
  FLUSH PRIVILEGES;

Revision as of 01:01, 31 October 2008

USE mysql;

REPLACE INTO user (host, user, password)
    VALUES (
        'localhost',
        'vmail_admin',
        PASSWORD('SuperSecret')
);

REPLACE INTO db (host, db, user, select_priv)
    VALUES (
        'localhost',
        'vmail',
        'vmail_admin',
        'Y'
);

-- Make sure that priviliges are reloaded.
FLUSH PRIVILEGES;

-- You should drop a pre-existing "vmail"
-- database manually to avoid CREATE errors.
CREATE DATABASE vmail;

USE vmail;

CREATE TABLE virtual_domains (
    id            INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    vdomain       VARCHAR(50) NOT NULL
    ) ENGINE = InnoDB;

CREATE TABLE relaydomains (
    id            INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    relaydomain   VARCHAR(80) NOT NULL,
    transport     VARCHAR(80) NOT NULL
    ) ENGINE = InnoDB;

CREATE TABLE virtual_users (
    id            INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    domain_id     INT(11) NOT NULL,
    user          VARCHAR(40) NOT NULL,
    passwd        VARCHAR(32) NOT NULL
    ) ENGINE = InnoDB;

CREATE TABLE virtual_aliases (
    id            INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    domain_id     INT(11) NOT NULL,
    source        VARCHAR(80) NOT NULL,
    destination   VARCHAR(80) NOT NULL,
    FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
    ) ENGINE = InnoDB;

FLUSH PRIVILEGES;