#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_druhk integer NOT NULL DEFAULT (0)::integer,
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    id_man character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    prn_no character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    zmena timestamp without time zone NOT NULL DEFAULT now(),
    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='<TABLENAME>' and column_name='idriadok_master') THEN
		ALTER TABLE <SCHEMA>.umdruhy  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='<TABLENAME>' and column_name='id_sync') THEN
		ALTER TABLE <SCHEMA>.umdruhy  ADD COLUMN id_sync integer NOT NULL DEFAULT 0;
	END IF;

	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN c_druhk SET NOT NULL;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN id_kas SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN id_kas SET NOT NULL;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN id_man SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN id_man SET NOT NULL;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN prn_no SET DEFAULT ''::bpchar;
	ALTER TABLE <SCHEMA>.umdruhy  ALTER COLUMN prn_no SET NOT NULL;

END IF;

#[ KONEC SOUBORU ]#