You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add upgrade script template and update README guidelines
Adds _template.sql with the required SET options and USE PerformanceMonitor
preamble so future upgrade scripts don't repeat the #828 mistake. Updates
the README example to match the actual pattern used by all upgrade scripts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: upgrades/README.md
+30-11Lines changed: 30 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,30 +36,49 @@ The installer:
36
36
37
37
## Upgrade Script Guidelines
38
38
39
-
1.**Always check before altering**: Use `IF NOT EXISTS` checks before adding columns/indexes
40
-
2.**Be idempotent**: Scripts should be safe to run multiple times
41
-
3.**Preserve data**: Never DROP tables with data (use ALTER/UPDATE instead)
42
-
4.**Add comments**: Document why each change is being made
43
-
5.**Test upgrade paths**: Test upgrading from each previous version
39
+
1.**Start from `_template.sql`**: Copy the template for every new upgrade script — it has the required SET options and `USE PerformanceMonitor` that the installer depends on
40
+
2.**Always check before altering**: Use `IF NOT EXISTS` / `IF EXISTS` checks before adding or modifying columns/indexes
41
+
3.**Be idempotent**: Scripts should be safe to run multiple times
42
+
4.**Preserve data**: Never DROP tables with data (use ALTER/UPDATE instead)
43
+
5.**Add comments**: Document why each change is being made
44
+
6.**Test upgrade paths**: Test upgrading from each previous version
44
45
45
46
## Example Upgrade Script
46
47
47
48
```sql
48
49
/*
50
+
Copyright 2026 Darling Data, LLC
51
+
https://www.erikdarling.com/
52
+
49
53
Upgrade from 1.0.0 to 1.1.0
50
54
Adds execution context tracking to query_stats
51
55
*/
52
56
53
-
-- Add new column if it doesn't exist
54
-
IF NOT EXISTS (
55
-
SELECT1/0
57
+
SET ANSI_NULLS ON;
58
+
SET ANSI_PADDING ON;
59
+
SET ANSI_WARNINGS ON;
60
+
SET ARITHABORT ON;
61
+
SET CONCAT_NULL_YIELDS_NULL ON;
62
+
SET QUOTED_IDENTIFIER ON;
63
+
SET NUMERIC_ROUNDABORT OFF;
64
+
SET IMPLICIT_TRANSACTIONS OFF;
65
+
SET STATISTICS TIME, IO OFF;
66
+
GO
67
+
68
+
USE PerformanceMonitor;
69
+
GO
70
+
71
+
IF NOT EXISTS
72
+
(
73
+
SELECT
74
+
1/0
56
75
FROMsys.columns
57
-
WHERE object_id = OBJECT_ID('collect.query_stats')
58
-
AND name ='execution_context'
76
+
WHERE object_id = OBJECT_ID(N'collect.query_stats')
77
+
ANDname =N'execution_context'
59
78
)
60
79
BEGIN
61
80
ALTERTABLEcollect.query_stats
62
-
ADD execution_context nvarchar(128) NULL;
81
+
ADD execution_context nvarchar(128) NULL;
63
82
64
83
PRINT 'Added execution_context column to collect.query_stats';
0 commit comments