#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok serial,
    nazmist character(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pozadi bytea,
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mistnost integer NOT NULL 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='selmist' and column_name='cidmaster') THEN
		ALTER TABLE <SCHEMA>.selmist ADD COLUMN cidmaster INTEGER DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='selmist' and column_name='mistpozadi') THEN
		ALTER TABLE <SCHEMA>.selmist DROP COLUMN mistpozadi;
	END IF;
END IF;

#[ KONEC SOUBORU ]#