#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    cislo numeric(20,10) DEFAULT (0),
    docid numeric(20,10) DEFAULT (0),
    typpoh numeric(20,10) DEFAULT (0),
    datpoh character(10) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    caspoh character(5) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    koduzv character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    kodfrm character(10) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    cisobj numeric(20,10) DEFAULT (0),
    kodobj character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp1sdh character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp2sdh character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp3sdh character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    eankod character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    cisskk character(15) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    mnoz numeric(20,10) DEFAULT (0),
    jedskk character(5) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    kodskl character(17) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    kodbth character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    datvyr character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp1sdp character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp2sdp character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vp3sdp character(40) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    kodskl2 character varying(17) COLLATE pg_catalog."default" DEFAULT '0'::character varying,
    cisbal numeric(20,10) DEFAULT (0),
    eanbal character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vahbal numeric(20,10) DEFAULT (0),
    cispol character(10) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vs1obj character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    vs2obj character(20) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    c_dokl integer DEFAULT (0)::integer,
    subor character(50) COLLATE pg_catalog."default" DEFAULT '0'::bpchar,
    id_suboru integer DEFAULT (0)::integer,
    idriadok SERIAL,
    CONSTRAINT bartech_idriadok PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='bartech' and column_name='kodskl') THEN
		ALTER TABLE <SCHEMA>.bartech ALTER COLUMN kodskl TYPE bpchar(20) USING kodskl::bpchar;
	END IF;
	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='bartech' and column_name='kodskl2') THEN
		ALTER TABLE <SCHEMA>.bartech ALTER COLUMN kodskl2 TYPE bpchar(20) USING kodskl2::bpchar;
	END IF;

END IF;

#[ KONEC SOUBORU ]#