alter table fastdial_company add column address varchar(50);
update fastdial_company set address = '' where address IS NULL;
alter table fastdial_company alter column address set not null;
alter table fastdial_company alter column address set default '';

alter table fastdial_company add column zipcode varchar(10);
update fastdial_company set zipcode = '' where zipcode IS NULL;
alter table fastdial_company alter column zipcode set not null;
alter table fastdial_company alter column zipcode set default '';

alter table fastdial_company add column city varchar(50);
update fastdial_company set city = '' where city IS NULL;
alter table fastdial_company alter column city set not null;
alter table fastdial_company alter column city set default '';

alter table fastdial_company add column country integer;
update fastdial_company set country = '2' where country IS NULL;
alter table fastdial_company alter column country set not null;
alter table fastdial_company alter column country set default '2';

alter table fastdial_company add column field1 varchar(64);
update fastdial_company set field1 = '' where field1 IS NULL;
alter table fastdial_company alter column field1 set not null;
alter table fastdial_company alter column field1 set default '';

alter table fastdial_company add column field2 varchar(64);
update fastdial_company set field2 = '' where field2 IS NULL;
alter table fastdial_company alter column field2 set not null;
alter table fastdial_company alter column field2 set default '';

alter table fastdial_company add column field3 varchar(64);
update fastdial_company set field3 = '' where field3 IS NULL;
alter table fastdial_company alter column field3 set not null;
alter table fastdial_company alter column field3 set default '';

alter table fastdial_company add column field4 varchar(64);
update fastdial_company set field4 = '' where field4 IS NULL;
alter table fastdial_company alter column field4 set not null;
alter table fastdial_company alter column field4 set default '';

alter table fastdial_company add column field5 varchar(64);
update fastdial_company set field5 = '' where field5 IS NULL;
alter table fastdial_company alter column field5 set not null;
alter table fastdial_company alter column field5 set default '';

alter table fastdial_contact add column address varchar(50);
update fastdial_contact set address = '' where address IS NULL;
alter table fastdial_contact alter column address set not null;
alter table fastdial_contact alter column address set default '';

alter table fastdial_contact add column zipcode varchar(10);
update fastdial_contact set zipcode = '' where zipcode IS NULL;
alter table fastdial_contact alter column zipcode set not null;
alter table fastdial_contact alter column zipcode set default '';

alter table fastdial_contact add column city varchar(50);
update fastdial_contact set city = '' where city IS NULL;
alter table fastdial_contact alter column city set not null;
alter table fastdial_contact alter column city set default '';

alter table fastdial_contact add column country integer;
update fastdial_contact set country = '2' where country IS NULL;
alter table fastdial_contact alter column country set not null;
alter table fastdial_contact alter column country set default '2';

alter table fastdial_contact add column field1 varchar(64);
update fastdial_contact set field1 = '' where field1 IS NULL;
alter table fastdial_contact alter column field1 set not null;
alter table fastdial_contact alter column field1 set default '';

alter table fastdial_contact add column field2 varchar(64);
update fastdial_contact set field2 = '' where field2 IS NULL;
alter table fastdial_contact alter column field2 set not null;
alter table fastdial_contact alter column field2 set default '';

alter table fastdial_contact add column field3 varchar(64);
update fastdial_contact set field3 = '' where field3 IS NULL;
alter table fastdial_contact alter column field3 set not null;
alter table fastdial_contact alter column field3 set default '';

alter table fastdial_contact add column field4 varchar(64);
update fastdial_contact set field4 = '' where field4 IS NULL;
alter table fastdial_contact alter column field4 set not null;
alter table fastdial_contact alter column field4 set default '';

alter table fastdial_contact add column field5 varchar(64);
update fastdial_contact set field5 = '' where field5 IS NULL;
alter table fastdial_contact alter column field5 set not null;
alter table fastdial_contact alter column field5 set default '';

CREATE TABLE extrafield (
 id serial,

 created timestamp with time zone not null default CURRENT_TIMESTAMP,
--HELP_EN_INFO:Creation Date
--HELP_EN_LONG:The date and time this record was created.
--HELP_NL_INFO:Datum aanmaak
--HELP_NL_LONG:De tijd en datum waarop dit is aangemaakt.

 lastupdate timestamp with time zone not null default CURRENT_TIMESTAMP,
--HELP_EN_INFO:Last Update
--HELP_EN_LONG:The date and time this record was updated.
--HELP_NL_INFO:Laatste wijziging
--HELP_NL_LONG:De tijd en datum van laatste wijziging.

 company integer NOT NULL,
--HELP_EN_INFO:company
--HELP_EN_LONG:The company this record belongs to.
--HELP_NL_INFO:bedrijf
--HELP_NL_LONG:Het bedrijf waar deze gegevens bij horen.

 tablename varchar(16) NOT NULL default '',
--HELP_EN_INFO:tablename
--HELP_EN_LONG:Name of the table where this field resides
--HELP_NL_INFO:naam tabel
--HELP_NL_LONG:Naam voor de tabel.

 number integer NOT NULL default '1',
--HELP_EN_INFO:number
--HELP_EN_LONG:Field number
--HELP_NL_INFO:nummer
--HELP_NL_LONG:Veld nummer

 type integer NOT NULL default '1',
--HELP_EN_INFO:name
--HELP_EN_LONG:Name for this field
--HELP_NL_INFO:naam
--HELP_NL_LONG:Naam voor dit veld

 name varchar(24) NOT NULL default '',
--HELP_EN_INFO:name
--HELP_EN_LONG:Name for this field
--HELP_NL_INFO:naam
--HELP_NL_LONG:Naam voor dit veld

 description text NOT NULL default '',
--HELP_EN_INFO:description
--HELP_EN_LONG:Description for this field
--HELP_NL_INFO:omschrijving
--HELP_NL_LONG:Een omschrijving voor dit veld.

 PRIMARY KEY  (id)
);

GRANT UPDATE, SELECT, INSERT, DELETE ON extrafield TO astium;
GRANT UPDATE, SELECT, INSERT, DELETE ON extrafield_id_seq TO astium;

