#[ ZACATEK SOUBORU ]#

#DEF <SCHEMA>    frontsql
#DEF <PRIMARYKEY> i_priestor
#DEF <TABLENAME> priestor

#[ CREATE TABLE ZACATEK ]#
    n_priestor character varying(40) COLLATE pg_catalog."default",
    i_usporiad integer,
    kapacita integer,
    prev_doba text COLLATE pg_catalog."default",
    cena1 numeric,
    cena2 numeric,
    cena3 numeric,
    cena4 numeric,
    cena5 numeric,
    cena6 numeric,
    cena7 numeric,
    cena8 numeric,
    cena9 numeric,
    cena10 numeric,
    nakl_cena numeric,
    pozn text COLLATE pg_catalog."default",
    zmaz boolean DEFAULT false,
    c_user integer,
    datcas timestamp without time zone DEFAULT '1971-01-01 00:00:00'::timestamp without time zone,
    i_cenn integer,
    dph numeric,
    i_priestor SERIAL,
    upratanie integer,
    CONSTRAINT pk_i_priestor PRIMARY KEY (i_priestor)
#[ CREATE TABLE KONEC ]#

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='frontsql' and table_name='priestor' and column_name='upratanie') THEN
		ALTER TABLE frontsql.priestor ADD COLUMN upratanie integer;
		ALTER TABLE frontsql.priestor ALTER COLUMN upratanie SET DEFAULT 0;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='frontsql' and table_name='priestor' and column_name='upratanie') THEN
		ALTER TABLE frontsql.priestor DROP COLUMN upratanie;
	END IF;
	ALTER TABLE frontsql.priestor ADD COLUMN upratanie integer;

END IF;

#[ KONEC SOUBORU ]#