#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    c_karty integer NOT NULL DEFAULT 0,
    nazev1 character varying(27) COLLATE pg_catalog."default",
    nazev2 character varying(27) COLLATE pg_catalog."default",
    nazev3 character varying(27) COLLATE pg_catalog."default",
    nazev4 character varying(27) COLLATE pg_catalog."default",
    nazev5 character varying(27) COLLATE pg_catalog."default",
    naz1 character varying(30) COLLATE pg_catalog."default",
    naz2 character varying(30) COLLATE pg_catalog."default",
    naz3 character varying(30) COLLATE pg_catalog."default",
    naz4 character varying(30) COLLATE pg_catalog."default",
    naz5 character varying(30) COLLATE pg_catalog."default",
    meno1 character varying(250) COLLATE pg_catalog."default",
    meno2 character varying(250) COLLATE pg_catalog."default",
    meno3 character varying(250) COLLATE pg_catalog."default",
    meno4 character varying(250) COLLATE pg_catalog."default",
    meno5 character varying(250) COLLATE pg_catalog."default",
    vyr_postup text COLLATE pg_catalog."default",
    c_data smallint NOT NULL DEFAULT 1,
    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='ktexty' and column_name='meno1') THEN
        ALTER TABLE <SCHEMA>.ktexty ALTER COLUMN meno1 TYPE varchar(250) USING meno1::varchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='ktexty' and column_name='meno2') THEN
        ALTER TABLE <SCHEMA>.ktexty ALTER COLUMN meno2 TYPE varchar(250) USING meno2::varchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='ktexty' and column_name='meno3') THEN
        ALTER TABLE <SCHEMA>.ktexty ALTER COLUMN meno3 TYPE varchar(250) USING meno3::varchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='ktexty' and column_name='meno4') THEN
        ALTER TABLE <SCHEMA>.ktexty ALTER COLUMN meno4 TYPE varchar(250) USING meno4::varchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='ktexty' and column_name='meno5') THEN
        ALTER TABLE <SCHEMA>.ktexty ALTER COLUMN meno5 TYPE varchar(250) USING meno5::varchar;
	END IF;
END IF;

#[ KONEC SOUBORU ]#