#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    c_karty integer NOT NULL DEFAULT 0,
    obrazok bytea,
    c_data smallint NOT NULL DEFAULT 1,
    alergeny integer NOT NULL DEFAULT 0,
    kal_zad numeric(20,10) NOT NULL DEFAULT 0,
    kalorie numeric(20,10) NOT NULL DEFAULT 0,
    cas1 integer NOT NULL DEFAULT 0,
    cas2 integer NOT NULL DEFAULT 0,
    cas3 integer NOT NULL DEFAULT 0,
    poznamka text COLLATE pg_catalog."default" NOT NULL DEFAULT ''::text,
    teplota integer NOT NULL DEFAULT 0,
    CONSTRAINT krest_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='krest' and column_name='straty') THEN
		ALTER TABLE IF EXISTS <SCHEMA>.krest ADD COLUMN straty numeric(5, 2) NOT NULL DEFAULT 0;
	END IF;

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

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

END IF;

#[ KONEC SOUBORU ]#