2013-04-25 17:19:14 +02:00
|
|
|
-- INSERT INTO domain__domain_option
|
|
|
|
-- SELECT domain_option_id, domain_id FROM domain
|
|
|
|
-- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
|
|
|
|
-- JOIN packet on ( unixuser.packet_id = packet.packet_id )
|
|
|
|
-- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ), domain_option
|
2013-04-29 20:01:09 +02:00
|
|
|
-- WHERE basepacket.basepacket_code = 'PAC/DW'
|
2013-04-25 17:19:14 +02:00
|
|
|
-- AND domain_option.domain_option_name = 'php' ;
|
|
|
|
|
|
|
|
-- DELETE FROM domain__domain_option
|
|
|
|
-- USING domain_option, domain
|
|
|
|
-- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
|
|
|
|
-- JOIN packet on ( unixuser.packet_id = packet.packet_id )
|
|
|
|
-- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
|
2013-04-29 20:01:09 +02:00
|
|
|
-- WHERE basepacket.basepacket_code != 'PAC/DW'
|
2013-04-25 17:19:14 +02:00
|
|
|
-- AND domain__domain_option.domain_option_id = domain_option.domain_option_id
|
|
|
|
-- AND domain_option.domain_option_name = 'php' ;
|
2013-04-17 18:02:19 +02:00
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
--
|
|
|
|
-- Name: packet_component_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
|
|
--
|
|
|
|
|
|
|
|
CREATE SEQUENCE packet_component_id_seq
|
|
|
|
INCREMENT BY 1
|
|
|
|
NO MAXVALUE
|
|
|
|
NO MINVALUE
|
|
|
|
CACHE 1;
|
|
|
|
|
2013-05-13 19:52:13 +02:00
|
|
|
CREATE SEQUENCE component_id_seq
|
|
|
|
INCREMENT BY 1
|
|
|
|
NO MAXVALUE
|
|
|
|
NO MINVALUE
|
|
|
|
CACHE 1;
|
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
ALTER TABLE packet_component ADD COLUMN packet_component_id integer
|
|
|
|
DEFAULT nextval(('"packet_component_id_seq"'::text)::regclass) NOT NULL;
|
2013-05-13 19:52:13 +02:00
|
|
|
|
|
|
|
ALTER TABLE component ADD COLUMN component_id integer
|
|
|
|
DEFAULT nextval(('"component_id_seq"'::text)::regclass) NOT NULL;
|
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
ALTER TABLE ONLY packet_component
|
|
|
|
DROP CONSTRAINT pk_packet_component;
|
2013-05-13 19:52:13 +02:00
|
|
|
|
|
|
|
ALTER TABLE ONLY component
|
|
|
|
DROP CONSTRAINT pk_component CASCADE;
|
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
ALTER TABLE ONLY packet_component
|
|
|
|
ADD CONSTRAINT pk_packet_component PRIMARY KEY (packet_component_id);
|
|
|
|
|
2013-05-13 19:52:13 +02:00
|
|
|
ALTER TABLE ONLY component
|
|
|
|
ADD CONSTRAINT pk_component PRIMARY KEY (component_id);
|
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
ALTER TABLE ONLY packet ADD COLUMN basepacket_id integer;
|
|
|
|
|
|
|
|
UPDATE packet SET basepacket_id = ( SELECT basepacket_id FROM packet_component
|
2013-05-13 19:52:13 +02:00
|
|
|
WHERE packet_component.packet_id = packet.packet_id LIMIT 1 );
|
|
|
|
|
2013-05-11 17:52:53 +02:00
|
|
|
ALTER TABLE ONLY packet
|
|
|
|
ADD CONSTRAINT base_packet_ref FOREIGN KEY (basepacket_id) REFERENCES basepacket(basepacket_id);
|
2013-05-13 19:52:13 +02:00
|
|
|
|
|
|
|
ALTER TABLE ONLY packet_component
|
|
|
|
DROP COLUMN basepacket_id;
|