#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id integer NOT NULL DEFAULT 0,
    c_karty integer NOT NULL DEFAULT 0,
    nazev character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    dph numeric(5,2) NOT NULL DEFAULT 0,
    mnozstvo numeric(20,10) NOT NULL DEFAULT 0,
    ean character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    idriadok SERIAL,
    cena numeric(20,10) NOT NULL DEFAULT 0,
    CONSTRAINT magnetica_pol_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='magnetica_pol' and column_name='mnozstvo' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.magnetica_pol  ALTER COLUMN mnozstvo TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.magnetica_pol  ALTER COLUMN mnozstvo SET DEFAULT 0;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='magnetica_pol' and column_name='cena' and data_type='double precision') THEN
		ALTER TABLE <SCHEMA>.magnetica_pol  ALTER COLUMN cena TYPE numeric(20, 10);
		ALTER TABLE <SCHEMA>.magnetica_pol  ALTER COLUMN cena SET DEFAULT 0;
	END IF;

END IF;

#[ KONEC SOUBORU ]#