rev scripts for new voisniff db schema

2.6
Richard Fuchs 14 years ago
parent 5c5dbe8506
commit eaaaa5a9f2

@ -0,0 +1,24 @@
use sipstats;
set autocommit=0;
alter table messages add column src_mac binary(6) not null after timestamp;
alter table messages add column dst_mac binary(6) not null after src_mac;
alter table messages drop column transport;
alter table messages add column header blob not null after dst_port;
alter table messages add column trailer blob not null after payload;
alter table messages add column was_fragmented tinyint unsigned not null after callee_uuid;
update messages m set
src_mac = (select src_mac from packets p, message_packets mp where p.id = mp.packet and mp.message = m.id limit 1),
dst_mac = (select dst_mac from packets p, message_packets mp where p.id = mp.packet and mp.message = m.id limit 1),
header = (select header from packets p, message_packets mp where p.id = mp.packet and mp.message = m.id limit 1),
trailer = (select trailer from packets p, message_packets mp where p.id = mp.packet and mp.message = m.id limit 1),
was_fragmented = if(length(payload) <= 1472, 0, 1);
drop table message_packets;
drop table packets;
rename table messages to packets;
commit;
set autocommit=1;

@ -0,0 +1,42 @@
use sipstats;
set autocommit=0;
rename table packets to messages;
create table packets like messages;
alter table packets drop column protocol;
alter table packets drop column src_ip;
alter table packets drop column dst_ip;
alter table packets drop column src_port;
alter table packets drop column dst_port;
alter table packets drop column method;
alter table packets drop column cseq_method;
alter table packets drop column call_id;
alter table packets drop column request_uri;
alter table packets drop column from_uri;
alter table packets drop column caller_uuid;
alter table packets drop column callee_uuid;
alter table packets drop column was_fragmented;
alter table packets add unique key (timestamp, src_mac, dst_mac, header(80));
insert into packets (id, timestamp, src_mac, dst_mac, header, payload, trailer) select id, timestamp, src_mac, dst_mac, header, payload, trailer from messages;
alter table messages drop column src_mac;
alter table messages drop column dst_mac;
alter table messages add column transport enum('UDP','TCP') not null after protocol;
alter table messages drop column header;
alter table messages drop column trailer;
alter table messages drop column was_fragmented;
CREATE TABLE `message_packets` (
`message` bigint(20) unsigned NOT NULL,
`packet` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`message`,`packet`),
KEY `packet` (`packet`)
) ENGINE=MyISAM;
insert into message_packets select id, id from messages;
commit;
set autocommit=1;
Loading…
Cancel
Save