Skip to content

Commit 9eef071

Browse files
Widen installation_history version columns to nvarchar(512) (#712) (#722)
@@Version can exceed 255 characters on some SQL Server editions. This caused installation_history inserts to fail, making the installer think it was always a fresh install. - Fresh installs: column defined as nvarchar(512) - Upgrades: ALTER COLUMN in 2.4.0-to-2.5.0 upgrade script - Idempotent: checks current max_length before altering Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 55182fd commit 9eef071

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

install/01_install_database.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ BEGIN
746746
installation_date datetime2(7) NOT NULL DEFAULT SYSDATETIME(),
747747
installer_version nvarchar(50) NOT NULL,
748748
installer_info_version nvarchar(100) NULL,
749-
sql_server_version nvarchar(255) NOT NULL,
750-
sql_server_edition nvarchar(255) NOT NULL,
749+
sql_server_version nvarchar(512) NOT NULL,
750+
sql_server_edition nvarchar(512) NOT NULL,
751751
installation_type nvarchar(20) NOT NULL, /*INSTALL, UPGRADE, REINSTALL*/
752752
previous_version nvarchar(50) NULL,
753753
installation_status nvarchar(20) NOT NULL, /*SUCCESS, FAILED, PARTIAL*/
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Widen sql_server_version and sql_server_edition columns in config.installation_history
3+
Some @@VERSION strings exceed 255 characters (#712)
4+
*/
5+
6+
IF EXISTS
7+
(
8+
SELECT
9+
1/0
10+
FROM sys.columns AS c
11+
WHERE c.object_id = OBJECT_ID(N'config.installation_history')
12+
AND c.name = N'sql_server_version'
13+
AND c.max_length = 510 /* nvarchar(255) = 510 bytes */
14+
)
15+
BEGIN
16+
ALTER TABLE config.installation_history
17+
ALTER COLUMN sql_server_version nvarchar(512) NOT NULL;
18+
19+
PRINT 'Widened config.installation_history.sql_server_version to nvarchar(512)';
20+
END;
21+
22+
IF EXISTS
23+
(
24+
SELECT
25+
1/0
26+
FROM sys.columns AS c
27+
WHERE c.object_id = OBJECT_ID(N'config.installation_history')
28+
AND c.name = N'sql_server_edition'
29+
AND c.max_length = 510
30+
)
31+
BEGIN
32+
ALTER TABLE config.installation_history
33+
ALTER COLUMN sql_server_edition nvarchar(512) NOT NULL;
34+
35+
PRINT 'Widened config.installation_history.sql_server_edition to nvarchar(512)';
36+
END;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01_widen_version_columns.sql

0 commit comments

Comments
 (0)