/*===============================================================*/
/* Upgrade struktury z wersji 49 do 50                           */
/*                                                               */
/* ponieważ zmienia się indeks, trzeba przekopiować całą tablicę */
/*===============================================================*/
create table FiscalReportVat_copy (
   PosId                numeric(9)           not null,
   FiscalReportId       numeric(9)           not null,
   Type                 smallint             not null,
   VatRateValue         decimal(6,2)         not null,
   Brutto               decimal(14,2)        null,
   Vat                  decimal(14,2)        null,
   constraint PK_FISCALREPORTVAT primary key (FiscalReportId, PosId, Type, VatRateValue)
)
GO

INSERT INTO FiscalReportVat_copy (PosId, FiscalReportId, Type, VatRateValue, Brutto, Vat) 
SELECT PosId, FiscalReportId, 0, VatRateValue, Brutto, Vat FROM FiscalReportVat
GO

DROP TABLE FiscalReportVat
GO

ALTER TABLE FiscalReportVat_copy RENAME TO FiscalReportVat
GO

UPDATE StructureVersion SET Version = 50
GO