module (..., package.seeall)

-- if a table_creation_script does not create the named table or throw an exception then you will get an infinite loop, so be careful

-- List of each device that we manage
provisioning_device_seq = {
	"CREATE SEQUENCE provisioning_device_seq",
}

-- Multi-to-multi mapping of devices to classes
devices_to_classes = {
	"CREATE TABLE devices_to_classes (device_id INTEGER, class_id INTEGER REFERENCES provisioning_classes)",
	"CREATE INDEX d2c_device_idx ON devices_to_classes (device_id)",
	"CREATE INDEX d2c_class_idx ON devices_to_classes (class_id)",
	-- Need to enforce that devices do not contain more than one class in the same class group (using triggers)
	-- Theoretically should also check on updates and updates of classes, but not going to bother
	"CREATE OR REPLACE FUNCTION check_class_groups() RETURNS TRIGGER AS $$ \
		BEGIN \
			PERFORM * from provisioning_classes join devices_to_classes using(class_id) where device_id=NEW.device_id and class_group_id=(select class_group_id from provisioning_classes where class_id=NEW.class_id); \
			IF FOUND THEN \
				RAISE EXCEPTION 'Device cannot have multiple classes within the same class group'; \
			END IF; \
			RETURN NEW; \
		END; \
	$$ LANGUAGE plpgsql",
	"CREATE TRIGGER check_class_trigger BEFORE INSERT ON devices_to_classes FOR EACH ROW EXECUTE PROCEDURE check_class_groups()",
}

-- List of different class groups
provisioning_class_groups = {
	"CREATE TABLE provisioning_class_groups (class_group_id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE, label VARCHAR(255) UNIQUE, seq INTEGER)",
	"INSERT INTO provisioning_class_groups VALUES(default, 'device', 'Device Model', '1')",
	"INSERT INTO provisioning_class_groups VALUES(default, 'services', 'Services', '2')",
}

-- List of different device classes
provisioning_classes = {
	"CREATE TABLE provisioning_classes (class_id SERIAL PRIMARY KEY, class_group_id INTEGER REFERENCES provisioning_class_groups, label VARCHAR(255), seq INTEGER)",
	"CREATE INDEX classes_group_idx ON provisioning_classes (class_group_id)",
	"CREATE INDEX classes_label_idx ON provisioning_classes (label)",
	-- Need to enforce that group/label combo is unique
	"CREATE UNIQUE INDEX classes_group_label_idx ON provisioning_classes (class_group_id, label)",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 320/321/330/331/335 SIP', '1')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 450 SIP', '2')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 550/560 SIP', '3')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 650/670 SIP', '4')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundStation IP 5000/6000/7000 SIP', '5')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 1500', '6')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Linksys Internet Phone Adapter PAP2T', '7')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Snom 300', '10')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Snom 320/360/370', '11')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Unsupported Phone', '999')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='services'), 'Standard Phone', '1')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='services'), 'Public Phone', '2')",
	"INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='services'), 'Hotline', '3')",
}

-- Multi-to-multi mapping of classes to parameter groups
classes_to_param_groups = {
	"CREATE TABLE classes_to_param_groups (class_id INTEGER REFERENCES provisioning_classes, group_id INTEGER REFERENCES provisioning_groups)",
	"CREATE INDEX c2g_class_idx ON classes_to_param_groups (class_id)",
	"CREATE INDEX c2g_group_idx ON classes_to_param_groups (group_id)",
	-- Need to enforce that classes do not contain more than one parameter group with same name (using triggers)
	-- Theoretically should also check on updates and updates of groups, but not going to bother
	"CREATE OR REPLACE FUNCTION check_group_names() RETURNS TRIGGER AS $$ \
	        BEGIN \
			PERFORM * from provisioning_groups join classes_to_param_groups using(group_id) where class_id=NEW.class_id and name=(select name from provisioning_groups where group_id=NEW.group_id); \
			IF FOUND THEN \
				RAISE EXCEPTION 'Classes cannot have multiple parameter groups with the same name'; \
			END IF; \
			RETURN NEW; \
		END; \
	$$ LANGUAGE plpgsql",
	"CREATE TRIGGER check_group_trigger BEFORE INSERT ON classes_to_param_groups FOR EACH ROW EXECUTE PROCEDURE check_group_names()",
	-- Devices
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 320/321/330/331/335 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 320/321/330/331/335 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 320/321/330/331/335 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 650/670 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundStation IP 5000/6000/7000 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundStation IP 5000/6000/7000 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Linksys Internet Phone Adapter PAP2T'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Linksys Internet Phone Adapter PAP2T'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Linksys Internet Phone Adapter PAP2T'), (SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Snom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Snom)'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Snom Device'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Unsupported Phone'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Unsupported)'))",
	-- Services
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Standard Phone'), (SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Public Phone'), (SELECT group_id FROM provisioning_groups WHERE label='Public Phone'))",
	"INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Hotline'), (SELECT group_id FROM provisioning_groups WHERE label='Hotline'))",
}

-- List of different parameter groups
provisioning_groups = {
	"CREATE TABLE provisioning_groups (group_id SERIAL PRIMARY KEY, name VARCHAR(255), label VARCHAR(255) UNIQUE, seq INTEGER)",
	"CREATE INDEX groups_name_idx ON provisioning_groups (name)",
	"INSERT INTO provisioning_groups VALUES(default, 'device', 'Linksys ATA Device', '1')",
	"INSERT INTO provisioning_groups VALUES(default, 'device', 'Polycom Device', '1')",
	"INSERT INTO provisioning_groups VALUES(default, 'device', 'Snom Device', '1')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 (Linksys)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 (Unsupported)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg2', 'Registration 2 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg2', 'Registration 2 (Linksys)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg2', 'Registration 2 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg3', 'Registration 3 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg3', 'Registration 3 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg4', 'Registration 4 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg4', 'Registration 4 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg5', 'Registration 5 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg5', 'Registration 5 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg6', 'Registration 6 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg6', 'Registration 6 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg7', 'Registration 7 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg7', 'Registration 7 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg8', 'Registration 8 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg8', 'Registration 8 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg9', 'Registration 9 (Polycom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg9', 'Registration 9 (Snom)', '10')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg10', 'Registration 10 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg10', 'Registration 10 (Snom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg11', 'Registration 11 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg11', 'Registration 11 (Snom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg12', 'Registration 12 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg12', 'Registration 12 (Snom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg13', 'Registration 13 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg14', 'Registration 14 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg15', 'Registration 15 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg16', 'Registration 16 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg17', 'Registration 17 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg18', 'Registration 18 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg19', 'Registration 19 (Polycom)', '11')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg20', 'Registration 20 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg21', 'Registration 21 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg22', 'Registration 22 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg23', 'Registration 23 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg24', 'Registration 24 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg25', 'Registration 25 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg26', 'Registration 26 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg27', 'Registration 27 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg28', 'Registration 28 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg29', 'Registration 29 (Polycom)', '12')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg30', 'Registration 30 (Polycom)', '13')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg31', 'Registration 31 (Polycom)', '13')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg32', 'Registration 32 (Polycom)', '13')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg33', 'Registration 33 (Polycom)', '13')",
	"INSERT INTO provisioning_groups VALUES(default, 'reg34', 'Registration 34 (Polycom)', '13')",
	"INSERT INTO provisioning_groups VALUES(default, 'services', 'Standard Phone', '21')",
	"INSERT INTO provisioning_groups VALUES(default, 'services', 'Public Phone', '22')",
	"INSERT INTO provisioning_groups VALUES(default, 'services', 'Hotline', '23')",
}

-- Multi-to-multi mapping of parameter groups to parameters
param_groups_to_params = {
	"CREATE TABLE param_groups_to_params (group_id INTEGER REFERENCES provisioning_groups, param_id INTEGER REFERENCES provisioning_params, value VARCHAR(255), editable BOOLEAN)",
	"CREATE INDEX g2p_group_idx ON param_groups_to_params (group_id)",
	"CREATE INDEX g2p_param_idx ON param_groups_to_params (param_id)",
	"CREATE INDEX g2p_editable_idx ON param_groups_to_params (editable)",
	"CREATE UNIQUE INDEX g2p_group_param_idx ON param_groups_to_params (group_id, param_id)",
	-- Device
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='template'), '/etc/provisioning/templates/linksysata-template.lua', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='mac'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='registrar'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmap'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='sntpserver'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='timezone'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='musiconhold'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Linksys ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='adminpassword'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='template'), '/etc/provisioning/templates/polycom-template.lua', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='mac'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='registrar'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmap'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmaptimeout'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='sntpserver'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='timezone'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='musiconhold'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='homepage'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='adminpassword'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='pcportenable'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='urldialingenable'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='template'), '/etc/provisioning/templates/snom-template.lua', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='mac'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='registrar'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmap'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmaptimeout'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='sntpserver'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='timezone'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='musiconhold'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='adminpassword'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='pcportenable'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='urldialingenable'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	-- Registrations
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Unsupported)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Unsupported)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 (Snom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 13 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 14 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 15 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 16 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 17 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 18 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 19 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 20 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 21 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 22 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 23 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 24 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 25 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 26 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 27 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 28 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 29 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 30 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 31 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 32 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 33 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 34 (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)",
	-- Services
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='forwarding'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='hotlineenable'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='callhistoryenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailbox'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailcallback'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='forwarding'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='hotlineenable'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='callhistoryenable'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='forwarding'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='hotlineenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='hotlinedestination'), null, true)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='callhistoryenable'), 'false', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)",
	"INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'false', false)",
}

-- List of each parameter used in any way for any device - mostly for how to display
provisioning_params = {
	"CREATE TABLE provisioning_params (param_id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE, type VARCHAR(255), label VARCHAR(255), descr VARCHAR(255), value VARCHAR(255), seq INTEGER, regexp VARCHAR(255), validate text)",
	"CREATE INDEX params_name_idx ON provisioning_params (name)",
	"INSERT INTO provisioning_params VALUES(default, 'mac', 'text', 'MAC Address', 'Capitalized hex digits with no puncuation', '', '1', '^%x%x%x%x%x%x%x%x%x%x%x%x$', E'local value, functions, params = ...\nvalue = string.upper(value)\nlocal others = functions.getselectresponse(\"SELECT count(*) FROM provisioning_values WHERE param_id=\\'\"..params.value.device.value.mac.param_id..\"\\' AND device_id!=\\'\"..params.value.device_id.value..\"\\' AND value=\\'\"..value..\"\\'\")\nif tonumber(others[1].count) > 0 then\n\treturn value, \"MAC Address must be unique\"\nend\nreturn value')",
	"INSERT INTO provisioning_params VALUES(default, 'template', 'select', 'Template', '', '', '2', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'registrar', 'text', 'SIP Registrar', '', '', '3', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'digitmap', 'text', 'Digit Map', 'Phone dial pattern based on section 2.1.5 of RFC 3435, plus a comma to turn dialtone back on', '', '4', '^[*#0-9xT|,.%[%]-]*$', null)",
	"INSERT INTO provisioning_params VALUES(default, 'digitmaptimeout', 'text', 'Digit Map Timeout', E'Timeout in seconds for each segment of digit map (separated by \\'|\\')', '', '5', '^[0-9|]*$', null)",
	"INSERT INTO provisioning_params VALUES(default, 'sntpserver', 'text', 'SNTP Server', '', '', '6', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'timezone', 'text', 'Posix Time Zone', 'See the expanded form (no colon) of TZ variable at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html', 'UTC0', '7', '^%a+[+-]?%d+', null)",
	"INSERT INTO provisioning_params VALUES(default, 'musiconhold', 'text', 'Music-on-hold URI', '', '', '8', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'homepage', 'text', 'Browser Homepage', '', '', '9', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'adminpassword', 'text', 'Administration Password', '', '', '10', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'pcportenable', 'boolean', 'PC Ethernet Port Enable', '', 'true', '11', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'urldialingenable', 'boolean', 'URL Dialing Enable', '', 'false', '12', '', null)",

	"INSERT INTO provisioning_params VALUES(default, 'extension', 'text', 'Extension', '', '', '101', '^%d*$', null)",
	"INSERT INTO provisioning_params VALUES(default, 'password', 'text', 'Password', '', '', '102', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardnoanswerenable', 'boolean', 'Forward on No-answer Enable', '', 'false', '103', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardnoanswer', 'text', 'Forward on No-answer Destination', 'Callers will be transferred to this extension when you don''t answer after 20 seconds', '', '104', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardbusyenable', 'boolean', 'Forward on Busy Enable', '', 'false', '105', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardbusy', 'text', 'Forward on Busy Destination', 'Callers will be transferred to this extension when the line is busy', '', '106', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardallenable', 'boolean', 'Forward All Calls Enable', '', 'false', '107', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwardall', 'text', 'Forward All Calls Destination', 'All calls will be transferred to this extension', '', '108', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'callerid', 'text', 'Caller ID String', '', '', '109', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'polycomringtone', 'select', 'Ring Tone (Polycom)', '', '2', '110', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'forwarding', 'boolean', 'Forwarding Enable', '', 'true', '201', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'hotlineenable', 'boolean', 'Hotline Enable', '', 'false', '202', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'hotlinedestination', 'text', 'Hotline Destination', '', '', '203', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'callhistoryenable', 'boolean', 'Call History Enable', '', 'true', '204', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'callwaitingenable', 'boolean', 'Call Waiting Enable', '', 'true', '205', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'speeddialenable', 'boolean', 'Speed Dial Enable', '', 'true', '206', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'mailbox', 'text', 'Voice Mailbox', 'Mailbox extension or URL', '', '207', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'mailcallback', 'text', 'Voice Mailbox Callback', 'Extension or URL for mailbox message retrieval', '', '208', '', null)",
	"INSERT INTO provisioning_params VALUES(default, 'databaseversion', 'text', 'Provisioning Database Version', 'Do not edit or delete!', '1', '999', '', null)"
}

-- All of the (non-default) parameter values for all devices are stored here
provisioning_values = {
	-- device_id is a device id from provisioning_device_seq and param_id is a param id from provisioning_params
	"CREATE TABLE provisioning_values (device_id INTEGER, group_name VARCHAR(255), param_id INTEGER REFERENCES provisioning_params, value VARCHAR(255))",
	"CREATE INDEX values_device_idx ON provisioning_values (device_id)",
	"CREATE INDEX values_group_idx ON provisioning_values (group_name)",
	"CREATE INDEX values_param_idx ON provisioning_values (param_id)",
	"CREATE UNIQUE INDEX values_device_group_param_idx ON provisioning_values (device_id, group_name, param_id)",
	-- Need to enforce that group_name is a valid name in provisioning_groups (cannot use foreign key because name is not unique in provisioning_groups)
	-- Better yet, we'll check for a valid combination of device, group, and param (using triggers)
	-- Theoretically should also check on updates and updates of devices, groups, or parameters, but not going to bother
	"CREATE OR REPLACE FUNCTION check_valid_param() RETURNS TRIGGER AS $$ \
	        BEGIN \
			PERFORM * from devices_to_classes d join provisioning_classes using(class_id) join classes_to_param_groups using(class_id) join provisioning_groups g using(group_id) join param_groups_to_params p using(group_id) where d.device_id=NEW.device_id and g.name=NEW.group_name and p.param_id=NEW.param_id; \
			IF NOT FOUND THEN \
				RAISE EXCEPTION 'Invalid combination of device, group, and parameter'; \
			END IF; \
			RETURN NEW; \
		END; \
	$$ LANGUAGE plpgsql",
	"CREATE TRIGGER valid_param_trigger BEFORE INSERT ON provisioning_values FOR EACH ROW EXECUTE PROCEDURE check_valid_param()",
}

-- List of options for parameters
provisioning_options = {
	"CREATE TABLE provisioning_options (param_id INTEGER REFERENCES provisioning_params, label VARCHAR(255), value VARCHAR(255), seq INTEGER)",
	"CREATE INDEX options_param_idx ON provisioning_options (param_id)",
	"CREATE UNIQUE INDEX options_param_label_idx ON provisioning_options (param_id, label)",
	-- Templates
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='template'), 'Polycom', '/etc/provisioning/templates/polycom-template.lua', '1')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='template'), 'Linksys ATA', '/etc/provisioning/templates/linksysata-template.lua', '2')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='template'), 'Snom', '/etc/provisioning/templates/snom-template.lua', '3')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Silent Ring', '1', '1')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Trill', '2', '2')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Double Trill', '3', '3')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Medium Trill', '4', '4')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Medium Double Trill', '5', '5')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'High Trill', '6', '6')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'High Double Trill', '7', '7')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Highest Trill', '8', '8')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Highest Double Trill', '9', '9')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Beeble', '10', '10')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Triplet', '11', '11')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Ringback-style', '12', '12')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Trill Precedence', '13', '13')",
	"INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Ring Splash', '14', '14')",
}

-- List of getfile requests
provisioning_requests = {
	"CREATE TABLE provisioning_requests (mac VARCHAR(12) unique, ip VARCHAR(15), agent VARCHAR(255), date timestamp)",
}
