Skip to content

Commit f194465

Browse files
Merge pull request #357 from erikdarlingdata/fix/upgrade-path-collect-flags
Move collect_query/collect_plan upgrade to proper upgrade path
2 parents c708942 + f0ee72c commit f194465

3 files changed

Lines changed: 66 additions & 41 deletions

File tree

install/01_install_database.sql

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -321,47 +321,6 @@ BEGIN
321321
PRINT 'Created config.collection_schedule table';
322322
END;
323323

324-
/*
325-
Add collect_query and collect_plan columns for existing installations
326-
Controls whether collectors store query text and execution plans
327-
Both default to enabled (1) for backwards compatibility
328-
*/
329-
IF NOT EXISTS
330-
(
331-
SELECT
332-
1/0
333-
FROM sys.columns
334-
WHERE object_id = OBJECT_ID(N'config.collection_schedule')
335-
AND name = N'collect_query'
336-
)
337-
BEGIN
338-
ALTER TABLE
339-
config.collection_schedule
340-
ADD collect_query bit NOT NULL
341-
CONSTRAINT DF_collection_schedule_collect_query
342-
DEFAULT CONVERT(bit, 'true');
343-
344-
PRINT 'Added collect_query column to config.collection_schedule';
345-
END;
346-
347-
IF NOT EXISTS
348-
(
349-
SELECT
350-
1/0
351-
FROM sys.columns
352-
WHERE object_id = OBJECT_ID(N'config.collection_schedule')
353-
AND name = N'collect_plan'
354-
)
355-
BEGIN
356-
ALTER TABLE
357-
config.collection_schedule
358-
ADD collect_plan bit NOT NULL
359-
CONSTRAINT DF_collection_schedule_collect_plan
360-
DEFAULT CONVERT(bit, 'true');
361-
362-
PRINT 'Added collect_plan column to config.collection_schedule';
363-
END;
364-
365324
/*
366325
Critical issues table
367326
Logs significant performance problems detected by collectors and analysis procedures
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Copyright 2026 Darling Data, LLC
3+
https://www.erikdarling.com/
4+
5+
Upgrade from 2.0.0 to 2.1.0
6+
Adds collect_query and collect_plan columns to config.collection_schedule
7+
for optional query text and execution plan collection (#337).
8+
Both default to 1 (enabled) to preserve existing behavior.
9+
*/
10+
11+
SET ANSI_NULLS ON;
12+
SET ANSI_PADDING ON;
13+
SET ANSI_WARNINGS ON;
14+
SET ARITHABORT ON;
15+
SET CONCAT_NULL_YIELDS_NULL ON;
16+
SET QUOTED_IDENTIFIER ON;
17+
SET NUMERIC_ROUNDABORT OFF;
18+
SET IMPLICIT_TRANSACTIONS OFF;
19+
SET STATISTICS TIME, IO OFF;
20+
GO
21+
22+
USE PerformanceMonitor;
23+
GO
24+
25+
/* Add collect_query column for optional query text collection */
26+
IF NOT EXISTS
27+
(
28+
SELECT
29+
1/0
30+
FROM sys.columns
31+
WHERE object_id = OBJECT_ID(N'config.collection_schedule')
32+
AND name = N'collect_query'
33+
)
34+
BEGIN
35+
ALTER TABLE
36+
config.collection_schedule
37+
ADD
38+
collect_query bit NOT NULL
39+
CONSTRAINT DF_collection_schedule_collect_query
40+
DEFAULT CONVERT(bit, 'true');
41+
42+
PRINT 'Added collect_query to config.collection_schedule';
43+
END;
44+
GO
45+
46+
/* Add collect_plan column for optional execution plan collection */
47+
IF NOT EXISTS
48+
(
49+
SELECT
50+
1/0
51+
FROM sys.columns
52+
WHERE object_id = OBJECT_ID(N'config.collection_schedule')
53+
AND name = N'collect_plan'
54+
)
55+
BEGIN
56+
ALTER TABLE
57+
config.collection_schedule
58+
ADD
59+
collect_plan bit NOT NULL
60+
CONSTRAINT DF_collection_schedule_collect_plan
61+
DEFAULT CONVERT(bit, 'true');
62+
63+
PRINT 'Added collect_plan to config.collection_schedule';
64+
END;
65+
GO
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01_collection_schedule_optional_text.sql

0 commit comments

Comments
 (0)