#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    rastr character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    kdy character(17) COLLATE pg_catalog."default" DEFAULT ' '::bpchar,
    kdo character varying(3) COLLATE pg_catalog."default" DEFAULT ' '::character varying,
    c_druh integer NOT NULL DEFAULT 0,
    id character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    idriadok SERIAL,
    c_data smallint NOT NULL DEFAULT 1,
    rastr1 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr2 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr3 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr4 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr5 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr6 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr7 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr8 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rastr9 character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    iddruh character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

#[ IF EXIST ZACATEK ]#
#[ PRIMARYKEY ]#

	UPDATE food600.fras_set  set rastr='' WHERE rastr is null;
	ALTER TABLE food600.fras_set  ALTER COLUMN rastr SET DEFAULT '';
	ALTER TABLE food600.fras_set  ALTER COLUMN rastr SET NOT NULL;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='iddruh') THEN
		ALTER TABLE <SCHEMA>.fras_set  ADD COLUMN iddruh character(2) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr1') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr1 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr2') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr2 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr3') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr3 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr4') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr4 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr5') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr5 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr6') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr6 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr7') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr7 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr8') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr8 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='fras_set' and column_name='rastr9') THEN
		ALTER TABLE <SCHEMA>.fras_set   ADD COLUMN rastr9 CHARACTER(5) NOT NULL DEFAULT '';
	END IF;

END IF;

#[ KONEC SOUBORU ]#