#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    id_kas character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_karty integer NOT NULL DEFAULT 0,
    cenovka character(250) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    zmazane smallint NOT NULL DEFAULT 0,
    CONSTRAINT cenovky_karty_<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='cena') THEN
		ALTER TABLE <SCHEMA>.<TABLENAME> ADD COLUMN cena numeric(20, 10) 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='cenovkaold') THEN
		ALTER TABLE <SCHEMA>.<TABLENAME> ADD COLUMN cenovkaold character(50) NOT NULL DEFAULT '';
	END IF;

	IF  EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='<TABLENAME>' and column_name='cenovka' and character_maximum_length in (250,50)) THEN
		ALTER TABLE <SCHEMA>.<TABLENAME> ALTER COLUMN cenovka TYPE character(150) COLLATE pg_catalog."default";
	END IF;

	IF  EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='<TABLENAME>' and column_name='cenovkaold' and character_maximum_length in (250,50)) THEN
		ALTER TABLE <SCHEMA>.<TABLENAME> ALTER COLUMN cenovkaold TYPE character(150) COLLATE pg_catalog."default";
	END IF;


END IF;
#[ KONEC SOUBORU ]#






