hs.hsadmin/hsarback/database/database_update.sql

57 lines
2.4 KiB
MySQL
Raw Normal View History

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' ;
--- Updates related to HSBilling
2013-04-25 17:19:14 +02:00
UPDATE bank_account SET autodebit_ar = false WHERE autodebit_ar IS NULL;
ALTER TABLE bank_account ALTER COLUMN autodebit_ar SET NOT NULL;
2013-04-25 17:19:14 +02:00
UPDATE bank_account SET autodebit_ga = false WHERE autodebit_ga IS NULL;
ALTER TABLE bank_account ALTER COLUMN autodebit_ga SET NOT NULL;
2013-04-25 17:19:14 +02:00
UPDATE bank_account SET autodebit_op = false WHERE autodebit_op IS NULL;
ALTER TABLE bank_account ALTER COLUMN autodebit_op SET NOT NULL;
2013-04-25 17:19:14 +02:00
ALTER TABLE basepacket ADD COLUMN article_number integer NOT NULL DEFAULT 1;
ALTER TABLE basepacket ALTER COLUMN article_number DROP DEFAULT;
2013-04-25 17:19:14 +02:00
ALTER TABLE component ADD COLUMN article_number integer NOT NULL DEFAULT 1;
ALTER TABLE component ALTER COLUMN article_number DROP DEFAULT;
2013-04-25 17:19:14 +02:00
CREATE TABLE price_list (
id serial PRIMARY KEY,
name varchar(20)
);
2013-04-25 17:19:14 +02:00
INSERT INTO price_list (name) VALUES ('Default Price List');
2013-04-25 17:19:14 +02:00
CREATE TABLE customer_price_list_mapping (
customer integer REFERENCES business_partner(bp_id),
price_list integer REFERENCES price_list(id),
PRIMARY KEY (customer, price_list)
);
2013-04-25 17:19:14 +02:00
INSERT INTO customer_price_list_mapping (SELECT bp_id, 1 FROM business_partner);
CREATE TABLE price (
id serial PRIMARY KEY,
article_number integer NOT NULL,
price decimal(10, 2) NOT NULL,
vat decimal(4,2) NOT NULL,
price_list integer REFERENCES price_list(id)
);
2013-04-25 17:19:14 +02:00
INSERT INTO price VALUES (1, 0, 0, 0, 1);