#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    typ character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    stav character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    postseqnr integer NOT NULL DEFAULT 0,
    cis_kasy character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    outlet character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pokoj character(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    odpoved character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pokoj1 character(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    folio1 character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    gn1 character(40) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pokoj2 character(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    folio2 character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    gn2 character(40) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pokoj3 character(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    folio3 character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    gn3 character(40) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pokoj4 character(8) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    folio4 character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    gn4 character(40) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    datum date,
    dat character(6) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    cas character(6) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    kecy character(25) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    idriadok SERIAL,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='db_in' and column_name='kecy') THEN
		ALTER TABLE <SCHEMA>.db_in ALTER COLUMN kecy TYPE bpchar(50) USING kecy::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='db_in' and column_name='gn1') THEN
		ALTER TABLE <SCHEMA>.db_in ALTER COLUMN gn1 TYPE bpchar(60) USING gn1::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='db_in' and column_name='gn2') THEN
		ALTER TABLE <SCHEMA>.db_in ALTER COLUMN gn2 TYPE bpchar(60) USING gn2::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='db_in' and column_name='gn3') THEN
		ALTER TABLE <SCHEMA>.db_in ALTER COLUMN gn3 TYPE bpchar(60) USING gn3::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='db_in' and column_name='gn4') THEN
		ALTER TABLE <SCHEMA>.db_in ALTER COLUMN gn4 TYPE bpchar(60) USING gn4::bpchar;
	END IF;

END IF;

#[ KONEC SOUBORU ]#