#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_partner integer NOT NULL DEFAULT 0,
    partner character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ico character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    dic character(14) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    banka character(25) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ucet character(25) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    telefon character(25) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz1 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz2 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz3 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz4 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz5 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    naz6 character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    splatnost numeric(20,10) NOT NULL DEFAULT 0,
    cen_hlad character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    sleva_proc numeric(20,10) NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    icdph character(16) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    alkokod character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ext_id integer NOT NULL DEFAULT 0,
    ext_intern character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    platcadph smallint NOT NULL DEFAULT 0,
    zmena timestamp without time zone NOT NULL DEFAULT now(),
    edi_kod character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    typ_obj smallint NOT NULL DEFAULT 0,
    edi_mankod smallint NOT NULL DEFAULT 0,
    platba character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    email character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    popis text COLLATE pg_catalog."default" NOT NULL DEFAULT ''::text,
    CONSTRAINT partneri_c_partner UNIQUE (c_partner),
    CONSTRAINT <TABLENAME>_<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='partneri' and column_name='edi_kod') THEN
		ALTER TABLE <SCHEMA>.partneri  ADD COLUMN edi_kod character(15) NOT NULL DEFAULT '';
	END IF;

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

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

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='email') THEN
			ALTER TABLE <SCHEMA>.partneri ADD COLUMN email character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='popis') THEN
		ALTER TABLE <SCHEMA>.partneri ADD COLUMN  popis TEXT  NOT NULL DEFAULT ''::TEXT;
	END IF;

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='fmeno') THEN
		ALTER TABLE <SCHEMA>.partneri ADD COLUMN fmeno character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='fulica') THEN
		ALTER TABLE <SCHEMA>.partneri ADD COLUMN fulica character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='fmesto') THEN
		ALTER TABLE <SCHEMA>.partneri ADD COLUMN fmesto character(50) NOT NULL DEFAULT '';
	END IF;

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='partneri' and column_name='funkcie') THEN
		ALTER TABLE IF EXISTS <SCHEMA>.partneri  ADD COLUMN funkcie CHARACTER(50) NOT NULL DEFAULT '';
	END IF;

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

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

END IF;

#[ KONEC SOUBORU ]#