#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    prn_no character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    prn_no_alt character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    prn_name character(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_name character(20) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    comment character(66) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cmd_on character(80) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cmd_off character(80) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cmd_cs character(80) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_reset character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_crlf character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_ff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_6lpi character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_8lpi character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_10cpi character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_12cpi character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_16cpi character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_boldon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_boldoff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_ulineon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_ulineoff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_wideon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_wideoff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_italon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_italoff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_draft character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_nlq character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_fullcut character(60) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_partcut character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_ucetfeed numeric NOT NULL DEFAULT 0,
    p_width character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_horiz character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    typ_diakr character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    cmd32_on character(80) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    ord_link character(2) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    ord_adr character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_kopii numeric NOT NULL DEFAULT 0,
    is_netprn smallint DEFAULT 0,
    p_header smallint DEFAULT 0,
    p_paragon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    p_paragoff character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ' '::bpchar,
    typ_fiskal character(10) COLLATE pg_catalog."default" NOT NULL DEFAULT 'ALTO'::bpchar,
    idriadok SERIAL,
    failed_bills integer NOT NULL DEFAULT 0,
    unrecoverable_bills integer NOT NULL DEFAULT 0,
    CONSTRAINT prn_def_<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='prn_def' and column_name='failed_bills') THEN
		ALTER TABLE <SCHEMA>.prn_def ADD COLUMN failed_bills integer not null default 0 ;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='prn_def' and column_name='unrecoverable_bills') THEN
		ALTER TABLE <SCHEMA>.prn_def ADD COLUMN unrecoverable_bills integer not null default 0 ;
	END IF;

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

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

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

	ALTER TABLE <SCHEMA>.prn_def  ALTER COLUMN p_fullcut TYPE character(60);

END IF;

#[ KONEC SOUBORU ]#
