#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id_limit integer NOT NULL DEFAULT 0,
    id_den integer NOT NULL DEFAULT 0,
    c_karty integer NOT NULL DEFAULT 0,
    cena_prod numeric(20,10) NOT NULL DEFAULT 0,
    dan numeric(5,3) NOT NULL DEFAULT 1,
    mnozstvi numeric(20,10) NOT NULL DEFAULT 0,
    poradie integer NOT NULL DEFAULT 0,
    c_stredisk integer NOT NULL DEFAULT 0,
    poznamka character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    vlastnik character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    nc numeric(20,10) NOT NULL DEFAULT 0,
    label smallint NOT NULL DEFAULT 0,
    dieta character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    vyber character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    idriadok SERIAL,
    c_data smallint NOT NULL DEFAULT 1,
    id_fmenu character(7) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT nlimitsablony_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='nlimitsablonypol' and column_name='id_fmenu') THEN
		 ALTER TABLE <SCHEMA>.nlimitsablonypol  ADD COLUMN id_fmenu character(7) NOT NULL DEFAULT '';
	END IF;

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

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='nlimitsablonypol' and column_name='c_hlad') THEN
		ALTER TABLE <SCHEMA>.nlimitsablonypol  ADD COLUMN c_hlad integer NOT NULL DEFAULT 0;
		UPDATE <SCHEMA>.nlimitsablonypol  SET c_hlad=1 WHERE c_hlad=0;		
	END IF;

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

END IF;

#[ KONEC SOUBORU ]#