/*==============================================================*/
/* Upgrade struktury z wersji 80 do 81                          */
/*==============================================================*/
CREATE TABLE LogTypeDef (
   TypeId               INTEGER              PRIMARY KEY,
   TypeCategory         text(50),
   Type                 INT                  NOT NULL,
   TypeValue            text(255)            NOT NULL,
   LastUpdate           datetime
)
GO

CREATE TABLE LogOperation (
   OperationId          INTEGER              PRIMARY KEY AUTOINCREMENT,
   PosId                numeric(9)           NOT NULL,
   OperatorId           numeric(9),
   AppTypeId            numeric(9)           NOT NULL,
   ModuleTypeId         numeric(9)           NOT NULL,
   OperationTypeId      numeric(9)           NOT NULL,
   OperationTime        datetime             NOT NULL,
   AdditionalDesc       text(255),
   ModItemId            text(30),
   ModTableTypeId       numeric(9),
   LastUpdate           datetime
)
GO

CREATE TABLE LogValChangeNum (
   ValChangeId          INTEGER              PRIMARY KEY AUTOINCREMENT,
   OperationId          numeric(9)           NOT NULL,
   ValChangeTypeId      numeric(9)           NOT NULL,
   ValueBefore          decimal(15,4)        NOT NULL,
   ValueAfter           decimal(15,4)        NOT NULL,
   LastUpdate           datetime
)
GO

CREATE TABLE LogValChangeTxt (
   ValChangeId          INTEGER              PRIMARY KEY AUTOINCREMENT,
   OperationId          numeric(9)           NOT NULL,
   ValChangeTypeId      numeric(9)           NOT NULL,
   ValueBefore          text(255)            NOT NULL,
   ValueAfter           text(255)            NOT NULL,
   LastUpdate           datetime
)
GO

/* Update numeru struktury */
UPDATE StructureVersion SET Version = 81
GO