#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    c_stredisk integer DEFAULT 0,
    c_dokl integer NOT NULL DEFAULT (0)::integer,
    c_doklod integer NOT NULL DEFAULT (0)::integer,
    c_dokldo integer NOT NULL DEFAULT (0)::integer,
    datum_dokl timestamp without time zone,
    zamok character(1) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mesiac character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    rok character(4) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ps numeric(20,10) NOT NULL DEFAULT (0),
    ks numeric(20,10) NOT NULL DEFAULT (0),
    ve numeric(20,10) NOT NULL DEFAULT (0),
    ze numeric(20,10) NOT NULL DEFAULT (0),
    vr numeric(20,10) NOT NULL DEFAULT (0),
    vv numeric(20,10) NOT NULL DEFAULT (0),
    zv numeric(20,10) NOT NULL DEFAULT (0),
    vk numeric(20,10) NOT NULL DEFAULT (0),
    pe numeric(20,10) NOT NULL DEFAULT (0),
    pv numeric(20,10) NOT NULL DEFAULT (0),
    pi numeric(20,10) NOT NULL DEFAULT (0),
    po numeric(20,10) NOT NULL DEFAULT (0),
    vo numeric(20,10) NOT NULL DEFAULT (0),
    pr numeric(20,10) NOT NULL DEFAULT (0),
    vp numeric(20,10) NOT NULL DEFAULT (0),
    pp numeric(20,10) NOT NULL DEFAULT (0),
    vb numeric(20,10) NOT NULL DEFAULT (0),
    pb numeric(20,10) NOT NULL DEFAULT (0),
    vc numeric(20,10) NOT NULL DEFAULT (0),
    pc numeric(20,10) NOT NULL DEFAULT (0),
    err numeric(20,10) NOT NULL DEFAULT (0),
    provedl character(3) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    exp_meno character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    c_mena smallint NOT NULL DEFAULT (1)::smallint,
    kdy timestamp without time zone,
    c_data smallint NOT NULL DEFAULT 1,
    idriadok SERIAL,
    label smallint NOT NULL DEFAULT 0,
    flag smallint NOT NULL DEFAULT 0,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

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


	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_data SET DEFAULT 1;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='zamok') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN zamok SET DEFAULT ''::bpchar;
		UPDATE <SCHEMA>.uzaverka SET zamok='' WHERE zamok='0';
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='mesiac') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN mesiac SET DEFAULT ''::bpchar;
		UPDATE <SCHEMA>.uzaverka SET mesiac='' WHERE mesiac='0';
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='rok') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN rok SET DEFAULT ''::bpchar;
		UPDATE <SCHEMA>.uzaverka SET rok='' WHERE rok='0';
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='provedl') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN provedl SET DEFAULT ''::bpchar;
		UPDATE <SCHEMA>.uzaverka SET provedl='' WHERE provedl='0';
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='exp_meno') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN exp_meno SET DEFAULT ''::bpchar;
		UPDATE <SCHEMA>.uzaverka SET exp_meno='' WHERE exp_meno='0';
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='c_mena') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_mena SET DEFAULT (1);
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='ps' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ps TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ps SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='ks' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ks TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ks SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='ve' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ve TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ve SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='ze' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ze TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ze SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vr' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vr TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vr SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vv' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vv TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vv SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='zv' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN zv TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN zv SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vk' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vk TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vk SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pe' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pe TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pe SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pv' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pv TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pv SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pi' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pi TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pi SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='po' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN po TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN po SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vo' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vo TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vo SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pr' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pr TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pr SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vp' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vp TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vp SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pp' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pp TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pp SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vb' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vb TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vb SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pb' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pb TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pb SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='vc' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vc TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vc SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='pc' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pc TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pc SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='err' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN err TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN err SET DEFAULT 0;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='uzaverka' and column_name='c_mena' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_mena TYPE smallint;
		ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_mena SET DEFAULT 1;
	END IF;

	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_dokl SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_doklod SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_dokldo SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN zamok SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN mesiac SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN rok SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ps SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ks SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ve SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN ze SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vr SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vv SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN zv SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vk SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pe SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pv SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pi SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN po SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vo SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pr SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vp SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pp SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vb SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pb SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN vc SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN pc SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN err SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN provedl SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN exp_meno SET NOT NULL;
	ALTER TABLE <SCHEMA>.uzaverka  ALTER COLUMN c_mena SET NOT NULL;

END IF;

#[ KONEC SOUBORU ]#