DROP TABLE IF EXISTS `location`;
CREATE TABLE `location` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(80) NOT NULL default '',
`ipaddr` varchar(15) NOT NULL default '',
`port` smallint(5) unsigned NOT NULL default '0',
`regrequest` int(11) NOT NULL default '0',
`regexpire` int(11) NOT NULL default '0',
`regtime` DATETIME NOT NULL default '2011-01-01 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM ROW_FORMAT=DYNAMIC;

DROP TRIGGER IF EXISTS `registration_trigger`;
CREATE TRIGGER registration_trigger BEFORE UPDATE ON sippeers
    FOR EACH ROW INSERT INTO location (name, ipaddr, port, regrequest, regexpire, regtime) VALUES (NEW.name, NEW.ipaddr, NEW.port, UNIX_TIMESTAMP(NOW()), NEW.regseconds, NOW());
