Skip to content

Commit 4d004ed

Browse files
Add 2.3.0-to-2.4.0 upgrade: re-apply growth/VLF columns
Servers that upgraded to 2.3.0 before PR #625 shipped don't have the is_percent_growth, growth_pct, and vlf_count columns. This re-applies the idempotent ALTER TABLE from the 2.2.0-to-2.3.0 upgrade for those servers.
1 parent 827b078 commit 4d004ed

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Copyright 2026 Darling Data, LLC
3+
https://www.erikdarling.com/
4+
5+
Upgrade from 2.3.0 to 2.4.0
6+
Re-applies growth/VLF columns for servers that upgraded to 2.3.0 before PR #625 shipped
7+
Adds growth settings and VLF count columns to collect.database_size_stats:
8+
9+
database_size_stats:
10+
- is_percent_growth: new column (bit NULL) — true when auto-growth is percent-based
11+
- growth_pct: new column (integer NULL) — raw growth percent value (set when is_percent_growth = 1)
12+
- vlf_count: new column (integer NULL) — VLF count for log files (NULL for data files)
13+
*/
14+
15+
SET ANSI_NULLS ON;
16+
SET ANSI_PADDING ON;
17+
SET ANSI_WARNINGS ON;
18+
SET ARITHABORT ON;
19+
SET CONCAT_NULL_YIELDS_NULL ON;
20+
SET QUOTED_IDENTIFIER ON;
21+
SET NUMERIC_ROUNDABORT OFF;
22+
SET IMPLICIT_TRANSACTIONS OFF;
23+
SET STATISTICS TIME, IO OFF;
24+
GO
25+
26+
USE PerformanceMonitor;
27+
GO
28+
29+
/*
30+
database_size_stats: add growth settings and VLF count columns
31+
*/
32+
IF OBJECT_ID(N'collect.database_size_stats', N'U') IS NOT NULL
33+
BEGIN
34+
PRINT 'Checking collect.database_size_stats columns...';
35+
36+
IF NOT EXISTS
37+
(
38+
SELECT
39+
1/0
40+
FROM INFORMATION_SCHEMA.COLUMNS
41+
WHERE TABLE_SCHEMA = N'collect'
42+
AND TABLE_NAME = N'database_size_stats'
43+
AND COLUMN_NAME = N'is_percent_growth'
44+
)
45+
BEGIN
46+
ALTER TABLE collect.database_size_stats ADD is_percent_growth bit NULL;
47+
PRINT ' is_percent_growth: added (bit NULL)';
48+
END;
49+
50+
IF NOT EXISTS
51+
(
52+
SELECT
53+
1/0
54+
FROM INFORMATION_SCHEMA.COLUMNS
55+
WHERE TABLE_SCHEMA = N'collect'
56+
AND TABLE_NAME = N'database_size_stats'
57+
AND COLUMN_NAME = N'growth_pct'
58+
)
59+
BEGIN
60+
ALTER TABLE collect.database_size_stats ADD growth_pct integer NULL;
61+
PRINT ' growth_pct: added (integer NULL)';
62+
END;
63+
64+
IF NOT EXISTS
65+
(
66+
SELECT
67+
1/0
68+
FROM INFORMATION_SCHEMA.COLUMNS
69+
WHERE TABLE_SCHEMA = N'collect'
70+
AND TABLE_NAME = N'database_size_stats'
71+
AND COLUMN_NAME = N'vlf_count'
72+
)
73+
BEGIN
74+
ALTER TABLE collect.database_size_stats ADD vlf_count integer NULL;
75+
PRINT ' vlf_count: added (integer NULL)';
76+
END;
77+
78+
PRINT 'database_size_stats complete.';
79+
END;
80+
ELSE
81+
BEGIN
82+
PRINT 'collect.database_size_stats not found — skipping.';
83+
END;
84+
GO
85+
86+
PRINT 'Upgrade 03_add_growth_vlf_columns complete.';
87+
GO
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01_add_growth_vlf_columns.sql

0 commit comments

Comments
 (0)