#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id_typ integer NOT NULL DEFAULT 0,
    id_chod integer NOT NULL DEFAULT 0,
    idriadok SERIAL,
    c_data smallint NOT NULL DEFAULT 1,
    poradie integer NOT NULL DEFAULT 1,
    posledny smallint NOT NULL DEFAULT 0,
    CONSTRAINT nlimittypchody_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='nlimittypchody' and column_name='posledny') THEN
		ALTER TABLE <SCHEMA>.nlimittypchody  ADD COLUMN posledny smallint NOT NULL DEFAULT 0;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='nlimittypchody' and column_name='idriadok_master') THEN
		ALTER TABLE <SCHEMA>.nlimittypchody  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='nlimittypchody' and column_name='id_sync') THEN
		ALTER TABLE <SCHEMA>.nlimittypchody  ADD COLUMN id_sync integer NOT NULL DEFAULT 0;
	END IF;

END IF;

#[ KONEC SOUBORU ]#