#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_stredisk integer NOT NULL DEFAULT 0,
    c_partner integer NOT NULL DEFAULT 0,
    c_karty integer NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 0,
    operace character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    idriadok SERIAL,
    mnozstvi numeric(20,10) NOT NULL DEFAULT 0,
    id_list integer NOT NULL DEFAULT 0,
    hlav smallint NOT NULL DEFAULT 0,
    meno_list character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pz1 character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    pz2 character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    poradie smallint NOT NULL DEFAULT 0,
    CONSTRAINT listovanie_idriadok PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='id_list') THEN
		ALTER TABLE <SCHEMA>.listovanie   ADD COLUMN  id_list integer NOT NULL DEFAULT 0;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='hlav') THEN
		ALTER TABLE <SCHEMA>.listovanie  ADD COLUMN  hlav smallint NOT NULL DEFAULT 0;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='meno_list') THEN
		ALTER TABLE <SCHEMA>.listovanie  ADD COLUMN  meno_list character(30) NOT NULL DEFAULT ''::bpchar;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='pz1') THEN
		ALTER TABLE <SCHEMA>.listovanie  ADD COLUMN  pz1 character(15) NOT NULL DEFAULT ''::bpchar;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='pz2') THEN
		ALTER TABLE <SCHEMA>.listovanie  ADD COLUMN  pz2 character(15) NOT NULL DEFAULT ''::bpchar;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='listovanie' and column_name='poradie') THEN
		ALTER TABLE <SCHEMA>.listovanie ADD COLUMN poradie smallint NOT NULL DEFAULT 0;
	END IF;

END IF;

#[ KONEC SOUBORU ]#