/*==============================================================*/
/* Upgrade struktury z wersji 81 do 82                          */
/*==============================================================*/
CREATE TABLE CodeDefinition (
   CodeDefId            INTEGER              PRIMARY KEY AUTOINCREMENT,
   Name                 text(255)            NOT NULL,
   IsActive             SMALLINT             NOT NULL,
   Type                 INT                  NOT NULL,
   DateFrom             datetime             NULL,
   DateTo               datetime             NULL,
   ExternalId           VARCHAR(20)          NULL,
   ExternalCentrId      VARCHAR(20)          NULL,
   LastUpdate           datetime
)
GO

CREATE TABLE CodeDefinitionElement (
   CodeDefId            INTEGER              NOT NULL,
   Ordinal              INT                  NOT NULL,
   Type                 SMALLINT             NOT NULL,
   CodeLength           SMALLINT             NOT NULL,
   TextValue            text(40)             NULL,
   constraint PK_CodeDefinitionElement PRIMARY KEY (CodeDefId, Ordinal)
)
GO

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