#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    u_cis character(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    autor character(3) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    text_sleva character(16) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    text_link character(26) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    uzaverka character(17) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    cena_celk numeric(20,10) NOT NULL DEFAULT 0,
    sleva_abs numeric(20,10) NOT NULL DEFAULT 0,
    cena_slev numeric(20,10) NOT NULL DEFAULT 0,
    dph_celk numeric(20,10) NOT NULL DEFAULT 0,
    trzba_dph1 numeric(20,10) NOT NULL DEFAULT 0,
    trzba_dph2 numeric(20,10) NOT NULL DEFAULT 0,
    trzba_dph3 numeric(20,10) NOT NULL DEFAULT 0,
    trzba_dph4 numeric(20,10) NOT NULL DEFAULT 0,
    dan1 numeric(20,10) NOT NULL DEFAULT 0,
    dan2 numeric(20,10) NOT NULL DEFAULT 0,
    dan3 numeric(20,10) NOT NULL DEFAULT 0,
    dan4 numeric(20,10) NOT NULL DEFAULT 0,
    u_cas character(14) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pocet_h numeric(20,10) NOT NULL DEFAULT 1,
    stul numeric(20,10) NOT NULL DEFAULT 0,
    cas_atrib character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mutace character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    u_open character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    uzcis character(14) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ducis character(4) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id_limit integer NOT NULL DEFAULT 0,
    lim_datum date,
    round50 numeric(20,10) NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    pohladavka smallint NOT NULL DEFAULT 0,
    id_den integer,
    id_chod integer,
    id_slave character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

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

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='sk_fin' and column_name='trzba_dph5') THEN
		ALTER TABLE <SCHEMA>.sk_fin DROP COLUMN trzba_dph5;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='sk_fin' and column_name='dan5') THEN
		ALTER TABLE <SCHEMA>.sk_fin DROP COLUMN dan5;
	END IF;

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

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='sk_fin' and column_name='text_link') THEN
		ALTER TABLE <SCHEMA>.sk_fin  ALTER COLUMN text_link TYPE character(26);
	END IF;

END IF;

#[ KONEC SOUBORU ]#