#[ ZACATEK SOUBORU ]#

#DEF <SCHEMA>    food600
#DEF <PRIMARYKEY> idriadok
#DEF <TABLENAME> fdct

#[ CREATE TABLE ZACATEK ]#
    c_pole character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    popis character(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    itemizer character(3) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

#[ IF EXIST ZACATEK ]#
#[ PRIMARYKEY ]#

	update <SCHEMA>.fdct set c_pole='' WHERE c_pole is null;
	ALTER TABLE <SCHEMA>.fdct  ALTER COLUMN c_pole TYPE character (5) COLLATE pg_catalog."default";
	ALTER TABLE <SCHEMA>.fdct  ALTER COLUMN c_pole SET DEFAULT '';
	ALTER TABLE <SCHEMA>.fdct  ALTER COLUMN c_pole SET NOT NULL;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fdct' and column_name='itemizer') THEN
		ALTER TABLE <SCHEMA>.fdct ADD COLUMN itemizer character(3) NOT NULL DEFAULT '';
	END IF;

END IF;
#[ KONEC SOUBORU ]#