#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    stul numeric(20,10) DEFAULT (0),
    kolik numeric(20,10) DEFAULT (0),
    vyber numeric(20,10) DEFAULT (0),
    delitel numeric(20,10) DEFAULT (0),
    kod character(13) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    id_man character(2) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    nazev character(30) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    spart character(1) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    pc numeric(20,10) DEFAULT (0),
    pr numeric(20,10) DEFAULT (0),
    druh character(10) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    prn_no character(2) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    selected character(1) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    blocked_by character(2) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    block_snr character(5) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    cena character(1) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    hras character(3) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    u_cis character(7) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    k_stornu numeric(20,10) DEFAULT (0),
    "time" character(5) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    pmx numeric(20,10) DEFAULT (0),
    cisnik character(15) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    idriadok SERIAL,
    CONSTRAINT uc_pol_idriadok 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='uc_pol' and column_name='idriadok') THEN
		ALTER TABLE <SCHEMA>.uc_pol  ADD COLUMN idriadok serial;
		ALTER TABLE <SCHEMA>.uc_pol ADD CONSTRAINT uc_pol_idriadok PRIMARY KEY (idriadok);
	END IF;

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

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

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

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

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

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uc_pol' and column_name='idupol') THEN
		ALTER TABLE <SCHEMA>.uc_pol  ADD COLUMN idupol serial;
	END IF;

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

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

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

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

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uc_pol' and column_name='popispoloz') THEN
		ALTER TABLE <SCHEMA>.uc_pol  ADD COLUMN popispoloz 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='uc_pol' and column_name='popis') THEN
		ALTER TABLE <SCHEMA>.uc_pol  ADD COLUMN popis 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='uc_pol' and column_name='slcasod') THEN
		ALTER TABLE <SCHEMA>.uc_pol  ADD COLUMN slcasod character(5)  NOT NULL DEFAULT ''::bpchar;
	END IF;

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

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

END IF;

#[ KONEC SOUBORU ]#