mirror of https://github.com/sipwise/db-schema.git
parent
243a612a89
commit
58515ef31c
@ -0,0 +1,20 @@
|
||||
use provisioning;
|
||||
|
||||
|
||||
alter table autoprov_devices
|
||||
add column `sync_uri` varchar(255) DEFAULT NULL,
|
||||
add column `sync_method` enum('GET','POST') DEFAULT 'GET',
|
||||
add column `sync_params` varchar(255) DEFAULT NULL,
|
||||
add column `security_handler` varchar(255) DEFAULT NULL,
|
||||
drop column `sync_type`;
|
||||
|
||||
update autoprov_devices d
|
||||
inner join autoprov_sync s on d.id=s.device_id
|
||||
inner join autoprov_sync_parameters p on p.id=s.parameter_id
|
||||
set d.sync_uri=if(p.parameter_name='sync_uri',s.parameter_value,d.sync_uri),
|
||||
d.sync_method=if(p.parameter_name='sync_method',s.parameter_value,d.sync_method),
|
||||
d.sync_params=if(p.parameter_name='sync_params',s.parameter_value,d.sync_params),
|
||||
d.security_handler=if(p.parameter_name='security_handler',s.parameter_value,d.security_handler);
|
||||
|
||||
drop table autoprov_sync;
|
||||
drop table autoprov_sync_parameters;
|
||||
@ -0,0 +1,45 @@
|
||||
use provisioning;
|
||||
|
||||
alter table autoprov_devices
|
||||
add column sync_type enum('http','zte_panasonic','zte_linksys') not null default 'http';
|
||||
|
||||
update autoprov_devices set sync_type='http' where vendor='Cisco';
|
||||
|
||||
create table autoprov_sync_parameters(
|
||||
`id` integer unsigned not null auto_increment primary key,
|
||||
`sync_type` enum('http','zte_panasonic','zte_linksys') not null default 'http',
|
||||
`parameter_name` enum('sync_uri','sync_method','sync_params','security_handler'),
|
||||
`parameter_constraint` varchar(255),
|
||||
UNIQUE KEY sync_parameter (sync_type,parameter_name)
|
||||
);
|
||||
insert into autoprov_sync_parameters(sync_type,parameter_name,parameter_constraint) values('http','sync_uri','');
|
||||
insert into autoprov_sync_parameters(sync_type,parameter_name,parameter_constraint) values('http','sync_params','');
|
||||
insert into autoprov_sync_parameters(sync_type,parameter_name,parameter_constraint) values('http','sync_method','/^(?:GET|POST)$/i');
|
||||
insert into autoprov_sync_parameters(sync_type,parameter_name,parameter_constraint) values('http','security_handler','');
|
||||
|
||||
create table autoprov_sync(
|
||||
`id` integer unsigned not null auto_increment primary key,
|
||||
`device_id` integer unsigned not null,
|
||||
`parameter_id` integer unsigned not null,
|
||||
`parameter_value` varchar(255),
|
||||
CONSTRAINT `a_s_paramid_ref` FOREIGN KEY (`parameter_id`) REFERENCES `autoprov_sync_parameters` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `a_s_deviceid_ref` FOREIGN KEY (`device_id`) REFERENCES `autoprov_devices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
insert into autoprov_sync(device_id,parameter_id,parameter_value)
|
||||
select a.id,p.id,a.val from (
|
||||
select id,'sync_uri' as name, sync_uri as val, sync_type from autoprov_devices
|
||||
union
|
||||
select id,'sync_method' as name, sync_method as val, sync_type from autoprov_devices
|
||||
union
|
||||
select id,'sync_params' as name, sync_params as val, sync_type from autoprov_devices
|
||||
union
|
||||
select id,'security_handler' as name, security_handler as val, sync_type from autoprov_devices
|
||||
) a inner join autoprov_sync_parameters p on a.name=p.parameter_name and a.sync_type=p.sync_type;
|
||||
|
||||
|
||||
alter table autoprov_devices
|
||||
drop column sync_uri,
|
||||
drop column sync_method,
|
||||
drop column sync_params,
|
||||
drop column security_handler;
|
||||
Loading…
Reference in new issue