database updates

This commit is contained in:
Peter Hormanns 2013-04-25 17:19:14 +02:00
parent e703647c0f
commit 34af930784

View File

@ -1,67 +1,56 @@
-- Migrate database from version 2.2 to version 2.3 -- 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
-- WHERE basepacket.basepacket_code = 'DW/B'
-- AND domain_option.domain_option_name = 'php' ;
--- Add domain option "php". -- DELETE FROM domain__domain_option
-- USING domain_option, domain
INSERT INTO domain_option (domain_option_name) -- JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
VALUES ('php'); -- JOIN packet on ( unixuser.packet_id = packet.packet_id )
-- JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
--- Set default values for pacs -- WHERE basepacket.basepacket_code != 'DW/B'
-- AND domain__domain_option.domain_option_id = domain_option.domain_option_id
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id -- AND domain_option.domain_option_name = 'php' ;
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
WHERE basepacket.basepacket_code = 'DW/B'
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 )
WHERE basepacket.basepacket_code != 'DW/B'
AND domain__domain_option.domain_option_id = domain_option.domain_option_id
AND domain_option.domain_option_name = 'php' ;
--- Updates related to HSBilling --- Updates related to HSBilling
update bank_account set autodebit_ar = false where autodebit_ar is null; UPDATE bank_account SET autodebit_ar = false WHERE autodebit_ar IS NULL;
alter table bank_account alter column autodebit_ar set not null; ALTER TABLE bank_account ALTER COLUMN autodebit_ar SET NOT NULL;
update bank_account set autodebit_ga = false where autodebit_ga is null; UPDATE bank_account SET autodebit_ga = false WHERE autodebit_ga IS NULL;
alter table bank_account alter column autodebit_ga set not null; ALTER TABLE bank_account ALTER COLUMN autodebit_ga SET NOT NULL;
update bank_account set autodebit_op = false where autodebit_op is null; UPDATE bank_account SET autodebit_op = false WHERE autodebit_op IS NULL;
alter table bank_account alter column autodebit_op set not null; ALTER TABLE bank_account ALTER COLUMN autodebit_op SET NOT NULL;
alter table basepacket add column article_number integer not null default 1; ALTER TABLE basepacket ADD COLUMN article_number integer NOT NULL DEFAULT 1;
alter table basepacket alter column article_number drop default; ALTER TABLE basepacket ALTER COLUMN article_number DROP DEFAULT;
alter table component add column article_number integer not null default 1; ALTER TABLE component ADD COLUMN article_number integer NOT NULL DEFAULT 1;
alter table component alter column article_number drop default; ALTER TABLE component ALTER COLUMN article_number DROP DEFAULT;
create table price_list ( CREATE TABLE price_list (
id serial primary key, id serial PRIMARY KEY,
name varchar(20) name varchar(20)
); );
insert into price_list values (1, 'Default Price List'); INSERT INTO price_list (name) VALUES ('Default Price List');
create table customer_price_list_mapping ( CREATE TABLE customer_price_list_mapping (
customer integer references business_partner(bp_id), customer integer REFERENCES business_partner(bp_id),
price_list integer references price_list(id) price_list integer REFERENCES price_list(id),
PRIMARY KEY (customer, price_list)
); );
insert into customer_price_list_mapping (select bp_id, 1 from business_partner); INSERT INTO customer_price_list_mapping (SELECT bp_id, 1 FROM business_partner);
create table price ( CREATE TABLE price (
id serial primary key, id serial PRIMARY KEY,
article_number integer not null, article_number integer NOT NULL,
price decimal(10, 2) not null, price decimal(10, 2) NOT NULL,
vat decimal(4,2) not null, vat decimal(4,2) NOT NULL,
price_list integer references price_list(id) price_list integer REFERENCES price_list(id)
); );
insert into price values (1, 0, 0, 0, 1); INSERT INTO price VALUES (1, 0, 0, 0, 1);
--
-- End of migration to version 2.3
--