2011-11-14 15:57:52 +01:00
|
|
|
drop table if exists `sph_counter`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `sph_counter` (
|
2011-11-14 15:57:52 +01:00
|
|
|
`counter_id` int not null,
|
|
|
|
`max_doc_id` int not null,
|
|
|
|
primary key (`counter_id`)
|
|
|
|
);
|
|
|
|
|
|
|
|
drop table if exists `sph_index`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `sph_index` (
|
2011-12-03 23:05:00 +01:00
|
|
|
`id` bigint not null,
|
2011-11-14 15:57:52 +01:00
|
|
|
`from` char(255) default null,
|
|
|
|
`to` text(512) default null,
|
|
|
|
`subject` text(512) default null,
|
|
|
|
`arrived` int not null,
|
|
|
|
`sent` int not null,
|
|
|
|
`body` text,
|
|
|
|
`size` int default '0',
|
2011-11-28 14:21:14 +01:00
|
|
|
`attachments` int default 0,
|
2011-11-14 15:57:52 +01:00
|
|
|
primary key (`id`)
|
|
|
|
) Engine=InnoDB;
|
|
|
|
|
2011-11-28 14:21:14 +01:00
|
|
|
|
2011-11-14 15:57:52 +01:00
|
|
|
drop table if exists `metadata`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `metadata` (
|
2011-11-14 15:57:52 +01:00
|
|
|
`id` bigint unsigned not null auto_increment,
|
|
|
|
`from` char(255) not null,
|
|
|
|
`subject` text(512) default null,
|
|
|
|
`arrived` int not null,
|
|
|
|
`sent` int not null,
|
|
|
|
`deleted` int default 0,
|
|
|
|
`size` int default 0,
|
|
|
|
`hlen` int default 0,
|
2011-11-22 12:31:54 +01:00
|
|
|
`attachments` int default 0,
|
2011-11-14 15:57:52 +01:00
|
|
|
`piler_id` char(36) not null,
|
|
|
|
`message_id` char(128) character set 'latin1' not null,
|
2011-11-22 12:31:54 +01:00
|
|
|
`digest` char(64) not null,
|
2011-11-14 15:57:52 +01:00
|
|
|
`bodydigest` char(64) not null,
|
2011-11-30 23:42:15 +01:00
|
|
|
primary key (`id`), unique(`message_id`)
|
2011-11-14 15:57:52 +01:00
|
|
|
) Engine=InnoDB;
|
|
|
|
|
|
|
|
create index metadata_idx on metadata(`piler_id`);
|
|
|
|
create index metadata_idx2 on metadata(`message_id`);
|
|
|
|
create index metadata_idx3 on metadata(`bodydigest`);
|
|
|
|
|
2011-12-03 23:05:00 +01:00
|
|
|
|
|
|
|
drop table if exists `rcpt`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `rcpt` (
|
2011-12-03 23:05:00 +01:00
|
|
|
`id` bigint unsigned not null,
|
|
|
|
`to` char(64) not null,
|
|
|
|
unique(`id`,`to`)
|
|
|
|
) Engine=InnoDB;
|
|
|
|
|
|
|
|
create index `rcpt_idx` on `rcpt`(`id`);
|
|
|
|
create index `rcpt_idx2` on `rcpt`(`to`);
|
|
|
|
|
|
|
|
|
2011-12-05 17:18:03 +01:00
|
|
|
drop view if exists `messages`;
|
|
|
|
create view `messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`rcpt`.`to` AS `to`,`metadata`.`subject` AS `subject` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
|
|
|
|
2011-11-19 21:25:44 +01:00
|
|
|
drop table if exists `attachment`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `attachment` (
|
2011-11-19 21:25:44 +01:00
|
|
|
`id` bigint unsigned not null auto_increment,
|
|
|
|
`piler_id` char(36) not null,
|
|
|
|
`attachment_id` int not null,
|
2011-11-28 14:21:14 +01:00
|
|
|
`name` char(64) default null,
|
|
|
|
`type` char(72) default null,
|
2011-11-19 21:25:44 +01:00
|
|
|
`sig` char(64) not null,
|
2011-11-23 12:24:21 +01:00
|
|
|
`size` int default 0,
|
2011-11-19 21:25:44 +01:00
|
|
|
`ptr` int default 0,
|
|
|
|
primary key (`id`)
|
|
|
|
) Engine=InnoDB;
|
|
|
|
|
|
|
|
create index `attachment_idx` on `attachment`(`piler_id`);
|
|
|
|
create index `attachment_idx2` on `attachment`(`sig`);
|
|
|
|
|
2011-12-03 23:05:00 +01:00
|
|
|
|
2011-12-05 17:18:03 +01:00
|
|
|
drop table if exists `tag`;
|
|
|
|
create table if not exists `tag` (
|
|
|
|
`id` bigint not null unique,
|
|
|
|
`tag` char(255) default null
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2011-11-19 21:25:44 +01:00
|
|
|
drop table if exists `archiving_rule`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `archiving_rule` (
|
2011-11-19 21:25:44 +01:00
|
|
|
`id` bigint unsigned not null auto_increment,
|
|
|
|
`from` char(128) default null,
|
|
|
|
`to` char(255) default null,
|
2011-11-22 14:25:51 +01:00
|
|
|
`subject` char(255) default null,
|
2011-11-19 21:25:44 +01:00
|
|
|
`_size` char(2) default null,
|
|
|
|
`size` int default 0,
|
2011-11-23 12:24:21 +01:00
|
|
|
`attachment_type` char(128) default null,
|
|
|
|
`_attachment_size` char(2) default null,
|
|
|
|
`attachment_size` int default 0,
|
2011-11-19 21:25:44 +01:00
|
|
|
primary key (`id`)
|
2011-11-23 12:24:21 +01:00
|
|
|
) ENGINE=InnoDB;
|
2011-11-19 21:25:44 +01:00
|
|
|
|
2011-11-14 15:57:52 +01:00
|
|
|
drop table if exists `counter`;
|
|
|
|
create table if not exists `counter` (
|
|
|
|
`rcvd` bigint unsigned default 0,
|
|
|
|
`virus` bigint unsigned default 0,
|
|
|
|
`duplicate` bigint unsigned default 0
|
|
|
|
) Engine=InnoDB;
|
|
|
|
|
|
|
|
insert into `counter` values(0, 0, 0);
|
|
|
|
|
2011-11-30 23:42:15 +01:00
|
|
|
drop table if exists `search`;
|
2011-12-05 17:18:03 +01:00
|
|
|
create table if not exists `search` (
|
2011-11-30 23:42:15 +01:00
|
|
|
`email` char(128) not null,
|
|
|
|
`ts` int default 0,
|
|
|
|
`term` text(512) not null
|
|
|
|
) Engine=InnoDB;
|
|
|
|
|
|
|
|
create index `search_idx` on `search`(`email`);
|
|
|
|
|
|
|
|
|