#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    datum character varying(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    c_dokl integer NOT NULL DEFAULT 0,
    id_man character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    druh character varying(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    partner character varying(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    castka numeric(12,2) NOT NULL DEFAULT 0,
    spdan numeric(12,2) NOT NULL DEFAULT 0,
    md character varying(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    dal character varying(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    md2 character varying(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    dal2 character varying(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    hs_md character varying(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    hs_dal character varying(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    pz character varying(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    poznamka character varying(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    zaloha smallint NOT NULL DEFAULT 0,
    faktura character varying(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    idriadok SERIAL,
    operace character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rok character(4) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mesiac character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    storno smallint NOT NULL DEFAULT 0,
    vymaz smallint NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    datum_dokl date,
    doklad integer NOT NULL DEFAULT 0,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

#[ IF EXIST ZACATEK ]#
#[ PRIMARYKEY ]#
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uexarchobraty' and column_name='dph') THEN
		ALTER TABLE <SCHEMA>.uexarchobraty ADD COLUMN dph numeric(5, 2) NOT NULL DEFAULT 1;
	END IF;

	ALTER TABLE <SCHEMA>.uexarchobraty  ALTER COLUMN md2 TYPE character(15) COLLATE pg_catalog."default";
	ALTER TABLE <SCHEMA>.uexarchobraty  ALTER COLUMN dal2 TYPE character(15) COLLATE pg_catalog."default";

END IF;


#[ KONEC SOUBORU ]#