#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_uzaverka integer NOT NULL DEFAULT 0,
    ucet integer NOT NULL DEFAULT 0,
    druh_pl character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cena_pl numeric(12,2) NOT NULL DEFAULT 0,
    tip numeric(10,2) NOT NULL DEFAULT 0,
    mena character(3) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cena_mena numeric(12,2) NOT NULL DEFAULT 0,
    poradi numeric(2,0) NOT NULL DEFAULT 0,
    text character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    kompez smallint NOT NULL DEFAULT 0,
    fik character varying(39) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    bkp character varying(44) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    cas_odesl character varying(13) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    preplatok numeric(12,2) DEFAULT 0,
    referencia integer DEFAULT 0,
    cena_real numeric(12,2) 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='sk__plt' and column_name='fik') THEN
		ALTER TABLE <SCHEMA>.sk__plt ADD COLUMN fik character varying(39) NOT NULL DEFAULT '';
	END IF;

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

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

	IF not EXISTS (SELECT column_name  FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='sk__plt' and column_name='preplatok') THEN
			ALTER TABLE <SCHEMA>.sk__plt   ADD COLUMN preplatok numeric(12,2) DEFAULT 0;
	END IF;
	
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' AND table_name='sk__plt' AND column_name='referencia') THEN
		ALTER TABLE <SCHEMA>.sk__plt ADD COLUMN referencia INTEGER DEFAULT 0;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' AND table_name='sk__plt' AND column_name='cena_real') THEN
		ALTER TABLE <SCHEMA>.sk__plt ADD COLUMN cena_real NUMERIC(12,2) DEFAULT 0;
	END IF;

END IF;

#[ KONEC SOUBORU ]#