Documentation PI Nexus+ Documentation

PI Nexus+ / Reference

Schema Migrations

This reference describes how PI Nexus+ keeps its database schema in step with the installed version: the migration files, the ledger, and the time limits that apply.

Overview

This reference describes how PI Nexus+ keeps its database schema in step with the installed version: the migration files, the ledger, and the time limits that apply.

Who applies migrations

Applied byWhenRights
Database SetupAt installation, from Admin\MigrationsThe account running Database Setup
The web applicationAt every start, before it answers requests, when bootstrap.json existsService account, db_owner
Admin > SQL Server > ApplyOn requestApp pool identity, db_owner

The scanner service never applies migrations. At startup it waits, and retries, until the schema is current; its log then says why it is waiting.

Migration files

MigrationVersionContent
0001–00081.0 to 1.5.1Earlier releases
0009_release_1_6_01.6.0, unchanged in 1.6.1 and 1.6.2The 1.6.x schema
0010_release_1_7_01.7.0PI Adapter monitoring, point sources, sites, daily health history, host monitoring and the other 1.7.0 tables. Rebuilds one index on the AF attribute table

A new installation applies all files; an upgrade applies only the missing ones. Released files never change.

The ledger

Each migration is recorded in dbo.PINexusSchemaMigrations, shown under Admin > SQL Server:

ColumnMeaning
MigrationIdNumber, for example 0010
NameName from the file
AppVersionVersion that applied it, or DatabaseSetup
StartedAt, CompletedAt, DurationMsTiming
SucceededWhether it finished
ChecksumSHA-256 of the file. A mismatch with an applied migration stops the update with Applied migration ... has checksum ..., but this build expects ...
ErrorMessageError of a failed run

Never edit the ledger unless support asks you to.

Behaviour and limits

ItemValue
TransactionsOne transaction per migration. A failed or stopped migration is rolled back; earlier ones stay applied. The next start continues with it
ConcurrencyOne migration run at a time per database (SQL application lock PINexus.SchemaMigration, 60-second wait)
Statement timeout in the web application3,600 seconds
Statement timeout in Database Setup300 seconds
Start window of the web application120 minutes; under IIS at most 55 minutes. Set with startupMigrationTimeoutMinutes in bootstrap.json
IIS start limit60 minutes (startupTimeLimit="3600" in web.config)
When the start window endsThe running migration is rolled back, the web application starts without it and logs which migration ran out of time. Scans stay blocked. Finish with Admin > SQL Server > Apply
Interrupted migrationAdmin > SQL Server and the scanner log report that it "was started ... but never completed". It runs again from the start; no repair is needed

Status on Admin > SQL Server

CardValueMeaning
DatabaseReachableThe connection works
OfflineThe connection failed; the card shows the error
SchemaCompatibleAll migrations of this version are applied; the card names the schema version
Not readyMigrations are pending
UnknownCannot be checked while the database is offline
MigrationCurrentNothing pending
N pendingChoose Apply after confirming a backup exists
RunningThe web application is applying a migration. Large databases can take up to an hour; Apply waits for it
FailedThe last migration failed; the card shows the error
BackupA backup is recommended before the next schema upgrade
No historyNo ledger yet: run Database Setup or Apply