#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id_man character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    u_cis character(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_karty integer NOT NULL DEFAULT 0,
    nazev character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    prachy numeric(20,10) NOT NULL DEFAULT 0,
    dan numeric(20,10) NOT NULL DEFAULT 0,
    mnozstvi numeric(20,10) NOT NULL DEFAULT 0,
    stor_mno numeric(20,10) NOT NULL DEFAULT 0,
    cen_hlad character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    k_odpoctu character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    uzaverka character(17) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    blocked_by character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    selected character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    u_time character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    dotacia character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id_karty integer NOT NULL DEFAULT 0,
    jc numeric(20,10) NOT NULL DEFAULT 0,
    id_fmenu character(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    typpolozky character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    kompez smallint NOT NULL DEFAULT 0,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

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

IF NOT EXISTS (SELECT indexname FROM pg_indexes WHERE schemaname='<SCHEMA>' and tablename='<TABLENAME>' and indexname='sk_pol_uzaverka') THEN
DROP INDEX IF EXISTS <SCHEMA>.sk_pol_uzaverka;
CREATE INDEX sk_pol_uzaverka
    ON <SCHEMA>.sk_pol USING btree
    (uzaverka COLLATE pg_catalog."default" ASC NULLS LAST)
    TABLESPACE pg_default;
END IF; 
    IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='sk_pol' and column_name='procentosl' ) THEN
	ALTER TABLE <SCHEMA>.sk_pol ADD procentosl numeric(2, 0) NOT NULL DEFAULT 0;
    END IF;

END IF;


#[ KONEC SOUBORU ]#