INSERT INTO domain_option (domain_option_name) 
	VALUES ('greylisting');

INSERT INTO contactrole_ref (contact_id, role) 
	( SELECT contact_id, 'voting-right' FROM contact );
	
CREATE TABLE member_asset (
    member_asset_id integer NOT NULL,
    bp_id integer NOT NULL,
    date date,
    action character varying(60),
    amount numeric,
    comment character varying(160)
);

CREATE SEQUENCE member_asset_member_asset_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE member_asset_member_asset_id_seq OWNED BY member_asset.member_asset_id;

ALTER TABLE ONLY member_asset ALTER COLUMN member_asset_id SET DEFAULT nextval('member_asset_member_asset_id_seq'::regclass);
    
CREATE TABLE member_share (
    member_share_id integer NOT NULL,
    bp_id integer NOT NULL,
    date date,
    action character varying(60),
    quantity integer,
    comment character varying(160)
);

CREATE SEQUENCE member_share_member_share_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE member_share_member_share_id_seq OWNED BY member_share.member_share_id;
 
ALTER TABLE ONLY member_share ALTER COLUMN member_share_id SET DEFAULT nextval('member_share_member_share_id_seq'::regclass);

ALTER TABLE ONLY member_asset
    ADD CONSTRAINT pk_member_asset PRIMARY KEY (member_asset_id);

ALTER TABLE ONLY member_share
    ADD CONSTRAINT pk_member_share PRIMARY KEY (member_share_id);

ALTER TABLE ONLY member_asset
    ADD CONSTRAINT pk_member_asset PRIMARY KEY (member_asset_id);
   
ALTER TABLE business_partner DROP CONSTRAINT ckc_shares_signed_business;

ALTER TABLE business_partner DROP COLUMN shares_updated ;

ALTER TABLE business_partner DROP COLUMN shares_signed ;

CREATE TABLE pac_administration (
    pac_administration_id integer NOT NULL,
    contact_id integer NOT NULL,
    pac_id integer NOT NULL
);

CREATE SEQUENCE pac_administration_pac_administration_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE pac_administration_pac_administration_id_seq OWNED BY pac_administration.pac_administration_id;

ALTER TABLE ONLY pac_administration 
	ALTER COLUMN pac_administration_id SET DEFAULT nextval('pac_administration_pac_administration_id_seq'::regclass);
	
ALTER TABLE ONLY pac_administration
    ADD CONSTRAINT pk_pac_administration PRIMARY KEY (pac_administration_id);

ALTER TABLE ONLY pac_administration
    ADD CONSTRAINT pac_administration_contact_ref FOREIGN KEY (contact_id) REFERENCES contact(contact_id);

ALTER TABLE ONLY pac_administration
    ADD CONSTRAINT pac_administration_pac_ref FOREIGN KEY (pac_id) REFERENCES packet(packet_id);

ALTER TABLE ONLY contact
	ADD COLUMN login character varying(40);
