#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    master_id character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ucet_prn character(4) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ucet_no character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    poradie smallint NOT NULL DEFAULT (0)::smallint,
    CONSTRAINT kasa_ucp_idriadok PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='kasa_ucp' and column_name='poradie') THEN
		ALTER TABLE <SCHEMA>.kasa_ucp ADD COLUMN poradie smallint NOT NULL DEFAULT 0;
	END IF;

	ALTER TABLE <SCHEMA>.kasa_ucp ALTER COLUMN master_id SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.kasa_ucp ALTER COLUMN id SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.kasa_ucp ALTER COLUMN ucet_no SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.kasa_ucp ALTER COLUMN poradie SET DEFAULT 0::smallint;
	ALTER TABLE <SCHEMA>.kasa_ucp ALTER COLUMN ucet_prn SET DEFAULT ''::bpchar;

END IF;

#[ KONEC SOUBORU ]#