CREATE DATABASE `poczta` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT USAGE ON poczta.* TO poczta@localhost;
GRANT ALL ON poczta.* TO poczta@localhost IDENTIFIED BY 'twoje_haslo';
flush privileges;

USE `poczta`;


CREATE TABLE IF NOT EXISTS `black_hosts` (
  `id` bigint(20) NOT NULL auto_increment,
  `host` varchar(128) NOT NULL,
  `comment` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `black_senders` (
  `id` bigint(20) NOT NULL auto_increment,
  `adres` varchar(256) character set utf8 collate utf8_bin NOT NULL,
  `comment` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `domeny` (
  `nazwa` varchar(64) NOT NULL,
  `alias` varchar(64) NOT NULL,
  PRIMARY KEY  (`nazwa`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `exim_greylist` (
  `id` bigint(20) NOT NULL auto_increment,
  `relay_ip` varchar(80) default NULL,
  `sender` varchar(255) character set utf8 collate utf8_bin default NULL,
  `recipient` varchar(255) default NULL,
  `block_expires` datetime NOT NULL default '0000-00-00 00:00:00',
  `record_expires` datetime NOT NULL default '9999-12-31 23:59:59',
  `create_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `type` enum('AUTO','MANUAL') NOT NULL default 'MANUAL',
  `passcount` bigint(20) NOT NULL default '0',
  `blockcount` bigint(20) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `exim_greylist_log` (
  `id` bigint(20) NOT NULL auto_increment,
  `listid` bigint(20) NOT NULL,
  `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
  `kind` enum('deferred','accepted') NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `passwd` (
  `user` varchar(30) character set utf8 collate utf8_bin NOT NULL,
  `haslo` varchar(128) NOT NULL,
  PRIMARY KEY  (`user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `skrzynki` (
  `nazwa` varchar(32) NOT NULL,
  `domena` varchar(64) NOT NULL,
  `alias` varchar(1024) NOT NULL,
  `haslo` varchar(128) NOT NULL,
  `polaczenie` varchar(20) NOT NULL,
  `kto` varchar(200) NOT NULL,
  `blokada` int(2) NOT NULL default '0',
  `uid` smallint(6) NOT NULL default '5001',
  `gid` smallint(6) NOT NULL default '50',
  `shell` varchar(16) NOT NULL default '/sbin/nologin',
  `blok_ftp` smallint(6) NOT NULL default '0',
  `homedir` varchar(64) NOT NULL,
  `pol_ftp` varchar(20) NOT NULL,
  `quota_type` enum('user','group','class','all') NOT NULL default 'user',
  `per_session` enum('false','true') NOT NULL default 'false',
  `limit_type` enum('soft','hard') NOT NULL default 'soft',
  `bytes_in_avail` int(10) unsigned NOT NULL default '0',
  `bytes_in_used` int(10) unsigned NOT NULL default '0',
  `bytes_out_avail` int(10) unsigned NOT NULL default '0',
  `bytes_out_used` int(10) unsigned NOT NULL default '0',
  `bytes_xfer_avail` int(10) unsigned NOT NULL default '0',
  `bytes_xfer_used` int(10) unsigned NOT NULL default '0',
  `files_in_avail` int(10) unsigned NOT NULL default '0',
  `files_in_used` int(10) unsigned NOT NULL default '0',
  `files_out_avail` int(10) unsigned NOT NULL default '0',
  `files_out_used` int(10) unsigned NOT NULL default '0',
  `files_xfer_avail` int(10) unsigned NOT NULL default '0',
  `files_xfer_used` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`nazwa`,`domena`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `white_hosts` (
  `id` int(20) NOT NULL auto_increment,
  `host` varchar(128) NOT NULL,
  `comment` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `white_senders` (
  `id` bigint(20) NOT NULL auto_increment,
  `adres` varchar(256) character set utf8 collate utf8_bin NOT NULL,
  `comment` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `white_tos` (
  `id` bigint(20) NOT NULL auto_increment,
  `adres` varchar(256) NOT NULL,
  `comment` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
