-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate-from-older-versions.html
More file actions
423 lines (403 loc) · 24.5 KB
/
migrate-from-older-versions.html
File metadata and controls
423 lines (403 loc) · 24.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Upgrade or Migrate PostgreSQL on Windows — Safe Path and pg_upgrade</title>
<meta name="description" content="Upgrade or migrate PostgreSQL on Windows 10/11. Safer dump/restore path, pg_upgrade overview, pre-checks, post-migration validation, and rollback tips." />
<link rel="canonical" href="https://postgre-sql.github.io/migrate-from-older-versions.html" />
<meta name="last-modified" content="2026-05-01T13:06:51Z" />
<meta name="robots" content="index,follow" />
<meta name="theme-color" content="#336791" />
<!-- Open Graph -->
<meta property="og:type" content="article" />
<meta property="og:title" content="Upgrade or Migrate PostgreSQL on Windows — Safe Path and pg_upgrade" />
<meta property="og:description" content="Safer dump/restore path, pg_upgrade overview, pre-checks, post-migration validation, and rollback tips." />
<meta property="og:url" content="https://postgre-sql.github.io/migrate-from-older-versions.html" />
<meta property="og:site_name" content="PostgreSQL for Windows" />
<meta property="og:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Upgrade or Migrate PostgreSQL on Windows" />
<meta name="twitter:description" content="Dump/restore path and pg_upgrade overview for Windows." />
<meta name="twitter:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Icons -->
<link rel="icon" href="https://postgre-sql.github.io/favicon.svg" type="image/svg+xml" />
<link rel="alternate icon" href="https://postgre-sql.github.io/favicon.ico" />
<link rel="apple-touch-icon" href="https://postgre-sql.github.io/apple-touch-icon.png" />
<style>
:root{
--bg:#F8FAFC; --panel:#FFFFFF; --text:#0F172A; --muted:#334155; --primary:#336791; --primary-600:#2b5a75; --primary-700:#244a60; --accent:#3E7BB6; --success:#2F855A; --warning:#B7791F; --border:#E2E8F0; --focus:#F59E0B; --shadow:0 2px 10px rgba(15,23,42,.08);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0; color:var(--text); background:var(--bg); font:16px/1.55 system-ui,-apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji"}
a{color:var(--primary)}
a:focus, button:focus{outline:3px solid var(--focus); outline-offset:2px}
header{position:sticky; top:0; z-index:50; background:rgba(255,255,255,.9); backdrop-filter:saturate(180%) blur(8px); border-bottom:1px solid var(--border)}
.wrap{max-width:1100px; margin:0 auto; padding:0 16px}
.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 0}
.brand{display:flex; align-items:center; gap:10px; color:var(--primary-700); text-decoration:none; font-weight:700}
.brand svg{width:28px;height:28px}
nav ul{list-style:none; margin:0; padding:0; display:flex; gap:14px; flex-wrap:wrap}
nav a{display:inline-flex; align-items:center; gap:6px; text-decoration:none; color:var(--muted); padding:8px 10px; border-radius:8px}
nav a:hover{background:#eef2f7; color:var(--primary-700)}
.breadcrumbs{font-size:14px; color:var(--muted); padding:10px 0}
.breadcrumbs a{text-decoration:none; color:inherit}
.hero{background:linear-gradient(180deg, #fff 0%, #f3f7fb 100%); border-bottom:1px solid var(--border)}
.hero .inner{display:grid; grid-template-columns:1.1fr .9fr; gap:24px; padding:34px 0}
.hero h1{font-size:clamp(26px,3.3vw,38px); line-height:1.15; margin:8px 0 10px}
.hero p.sub{color:var(--muted); margin:0 0 18px}
.btn{appearance:none; border:0; border-radius:10px; padding:12px 16px; display:inline-flex; align-items:center; gap:10px; cursor:pointer; font-weight:700; text-decoration:none}
.btn-primary{background:var(--primary); color:#fff}
.btn-primary:hover{background:var(--primary-600)}
.btn-ghost{background:transparent; color:var(--primary-700); border:2px solid var(--primary-600)}
.btn-ghost:hover{background:#e8f0f9}
.cta-row{display:flex; gap:12px; flex-wrap:wrap}
.note{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:14px; margin-top:10px}
.section{padding:30px 0}
.section h2{margin:0 0 14px; font-size:22px}
.card-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:16px}
.card{background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:16px; box-shadow:var(--shadow)}
.card h3{margin:0 0 8px; font-size:18px}
.card p{margin:0; color:var(--muted)}
.list{margin:10px 0 0; padding-left:18px}
footer{margin-top:24px; border-top:1px solid var(--border); background:#fff}
.footer-inner{display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:18px 0}
.muted{color:var(--muted)}
.disclaimer{background:#fff; border:1px dashed var(--border); padding:14px; border-radius:12px; color:var(--muted)}
.mobile-cta{position:fixed; bottom:12px; left:12px; right:12px; display:none; z-index:30}
.mobile-cta .inner{background:#10263a; border-radius:14px; padding:10px; display:flex; justify-content:space-between; align-items:center; gap:10px; color:#e6f1fa; box-shadow:0 8px 22px rgba(0,0,0,.25)}
.mobile-cta .inner .btn{padding:10px 14px}
/* Cookie banner */
.cookie-banner{position:fixed; z-index:60; inset:auto 12px 12px 12px; background:#fff; border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); display:none}
.cookie-content{padding:14px; display:grid; grid-template-columns:1fr auto; gap:12px; align-items:start}
.cookie-actions{display:flex; gap:8px; flex-wrap:wrap}
.cookie-banner .btn{padding:10px 12px}
/* Responsive */
@media (max-width: 900px){
.hero .inner{grid-template-columns:1fr}
.card-grid{grid-template-columns:1fr 1fr}
.footer-inner{grid-template-columns:1fr}
}
@media (max-width: 640px){
.card-grid{grid-template-columns:1fr}
.mobile-cta{display:block}
}
</style>
<!-- SVG Sprite -->
<svg xmlns="http://www.w3.org/2000/svg" style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">
<symbol id="icon-download" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 3a1 1 0 011 1v8.586l2.293-2.293a1 1 0 111.414 1.414l-4.001 4a1 1 0 01-1.412 0l-4.001-4a1 1 0 011.414-1.414L11 12.586V4a1 1 0 011-1z"/>
<path d="M4 15a1 1 0 011-1h2a1 1 0 010 2H6v3h12v-3h-1a1 1 0 110-2h2a1 1 0 011 1v4a2 2 0 01-2 2H6a2 2 0 01-2-2v-4z"/>
</symbol>
<symbol id="icon-external" viewBox="0 0 24 24" fill="currentColor"><path d="M14 3a1 1 0 000 2h3.586l-8.293 8.293a1 1 0 001.414 1.414L19 6.414V10a1 1 0 002 0V4a1 1 0 00-1-1h-6z"/><path d="M5 6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5a1 1 0 10-2 0v5H5V8h5a1 1 0 100-2H5z"/></symbol>
<symbol id="icon-check" viewBox="0 0 24 24" fill="currentColor"><path d="M20.285 6.708a1 1 0 010 1.414l-9.192 9.192a1 1 0 01-1.414 0L3.715 11.55a1 1 0 111.414-1.414l5.1 5.1 8.485-8.485a1 1 0 011.571-.042z"/></symbol>
<symbol id="icon-info" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm0 6a1.25 1.25 0 110-2.5A1.25 1.25 0 0112 8zm1 9h-2v-6h2v6z"/></symbol>
<symbol id="icon-warning" viewBox="0 0 24 24" fill="currentColor"><path d="M12.882 2.773l9.02 15.625A2 2 0 0120.236 22H3.764a2 2 0 01-1.666-3.602l9.02-15.625a2 2 0 013.764 0zM11 9v5h2V9h-2zm1 8a1.25 1.25 0 100-2.5A1.25 1.25 0 0012 17z"/></symbol>
<symbol id="icon-close" viewBox="0 0 24 24" fill="currentColor"><path d="M6.225 4.811a1 1 0 011.414 0L12 9.172l4.361-4.361a1 1 0 111.414 1.414L13.414 10.586l4.361 4.361a1 1 0 01-1.414 1.414L12 12l-4.361 4.361a1 1 0 01-1.414-1.414l4.361-4.361-4.361-4.361a1 1 0 010-1.414z"/></symbol>
</svg>
<!-- GA4 base tag -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MHLW57MR8Q"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('consent','default', { 'analytics_storage':'denied', 'ad_storage':'denied' });
gtag('js', new Date());
gtag('config', 'G-MHLW57MR8Q', { anonymize_ip: true });
</script>
<!-- Schema.org JSON-LD -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://postgre-sql.github.io/"},
{"@type": "ListItem", "position": 2, "name": "Migrate from Older Versions", "item": "https://postgre-sql.github.io/migrate-from-older-versions.html"}
]
},
{
"@type": "SoftwareApplication",
"name": "PostgreSQL for Windows",
"operatingSystem": "Windows 11, Windows 10 (64-bit)",
"applicationCategory": "DatabaseApplication",
"softwareVersion": "18.3-3",
"downloadUrl": "https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe",
"offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD", "category": "free"},
"publisher": {"@type": "Organization", "name": "Unofficial PostgreSQL for Windows Guide", "url": "https://postgre-sql.github.io/"}
},
{
"@type":"HowTo",
"name":"Upgrade or Migrate PostgreSQL on Windows",
"totalTime":"PT20M",
"step": [
{"@type":"HowToStep","name":"Back up first","text":"Create backups of databases and roles. Test restore on a non-production machine if possible."},
{"@type":"HowToStep","name":"Choose path","text":"Either use safer dump/restore, or in-place upgrade with pg_upgrade (faster, requires compatibility)."},
{"@type":"HowToStep","name":"Stop service","text":"Stop the old PostgreSQL Windows service before upgrading."},
{"@type":"HowToStep","name":"Install new version","text":"Install the new PostgreSQL version side by side."},
{"@type":"HowToStep","name":"Migrate data","text":"Dump/restore into the new cluster, or run pg_upgrade following its checklist."},
{"@type":"HowToStep","name":"Verify & switch","text":"Start the new service, run validation queries, update clients, and decommission the old version when safe."}
]
},
{
"@type": "FAQPage",
"mainEntity": [
{"@type": "Question", "name": "What is the safest way to upgrade on Windows?", "acceptedAnswer": {"@type":"Answer","text":"Use dump/restore: back up roles and each database, install the new version, initialize a new cluster, restore backups, verify, and only then decommission the old cluster."}},
{"@type": "Question", "name": "When should I use pg_upgrade?", "acceptedAnswer": {"@type":"Answer","text":"Use pg_upgrade when compatibility conditions are met and downtime must be minimized. Always run the --check step first and keep a rollback plan."}},
{"@type": "Question", "name": "Can I roll back if something fails?", "acceptedAnswer": {"@type":"Answer","text":"Yes, if you kept your old data directory and backups. Stop the new service, restart the old service, and restore from backups if necessary."}},
{"@type": "Question", "name": "Do extensions affect upgrades?", "acceptedAnswer": {"@type":"Answer","text":"Yes. Verify extension compatibility with the target version. Some extensions may need to be upgraded or reinstalled."}}
]
}
]
}
</script>
</head>
<body>
<header>
<div class="wrap topbar">
<a class="brand" href="https://postgre-sql.github.io/" aria-label="PostgreSQL for Windows — home">
<svg aria-hidden="true"><use href="#icon-check"></use></svg>
<span>PostgreSQL for Windows</span>
</a>
<nav aria-label="Primary navigation">
<ul>
<li><a href="https://postgre-sql.github.io/download-windows.html"><svg width="16" height="16" aria-hidden="true"><use href="#icon-download"></use></svg> Download</a></li>
<li><a href="https://postgre-sql.github.io/offline-installer.html">Offline installer</a></li>
<li><a href="https://postgre-sql.github.io/odbc-driver-x64-x86.html">ODBC x64/x86</a></li>
<li><a href="https://postgre-sql.github.io/configure-windows-service.html">Service</a></li>
<li><a href="https://postgre-sql.github.io/fix-path-issues.html">PATH</a></li>
<li><a href="https://postgre-sql.github.io/migrate-from-older-versions.html">Migrate</a></li>
</ul>
</nav>
</div>
</header>
<div class="wrap breadcrumbs" aria-label="Breadcrumb">
<a href="https://postgre-sql.github.io/">Home</a> · <span>Migrate from Older Versions</span>
</div>
<section class="hero">
<div class="wrap inner">
<div>
<h1>Upgrade or Migrate PostgreSQL on Windows</h1>
<p class="sub">Two paths: safer dump/restore or faster in-place with pg_upgrade. Back up first, verify compatibility, and keep a rollback plan for Windows 10/11.</p>
<div class="cta-row">
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" aria-label="Download PostgreSQL 18.3-3 for Windows (64-bit)"
data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="20" height="20" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Get the installer</span>
</a>
<a class="btn btn-ghost" href="https://postgre-sql.github.io/configure-windows-service.html">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-external"></use></svg>
<span>Service tips</span>
</a>
</div>
<div class="note" role="note">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-info"></use></svg>
<span><strong>Tip:</strong> Keep the old data directory untouched until the new version is fully validated.</span>
</div>
</div>
<div>
<div class="card">
<h3>Pre‑upgrade checklist</h3>
<ul class="list">
<li>Confirm Windows 10/11 (64‑bit) and available disk space.</li>
<li>Back up databases and roles; test a restore if possible.</li>
<li>Stop background jobs and client connections during upgrade.</li>
<li>Verify extension compatibility with the target version.</li>
<li>Plan for downtime and have a rollback procedure.</li>
</ul>
</div>
</div>
</div>
</section>
<main class="wrap">
<section class="section" id="dump-restore">
<h2>Path A — Safer dump/restore migration</h2>
<div class="card">
<ol class="list">
<li><strong>Back up roles/globals</strong> to capture users and permissions.</li>
<li><strong>Back up each database</strong> to portable files. Keep them safe.</li>
<li><strong>Install the new version</strong> side-by-side; initialize a fresh data directory.</li>
<li><strong>Restore roles and databases</strong> into the new cluster.</li>
<li><strong>Validate</strong> with application smoke tests and integrity checks.</li>
<li><strong>Switch clients</strong> to the new instance; keep the old offline for rollback until confident.</li>
</ol>
<p class="muted">This path is simple and predictable, at the cost of longer downtime on large datasets.</p>
</div>
</section>
<section class="section" id="pg-upgrade">
<h2>Path B — In‑place upgrade with pg_upgrade (overview)</h2>
<div class="card">
<ol class="list">
<li><strong>Stop the old service.</strong> Ensure no processes hold locks on the data directory.</li>
<li><strong>Install the new version</strong> (binaries and tools) without removing the old.</li>
<li><strong>Run pg_upgrade checks</strong> to validate compatibility and directory paths.</li>
<li><strong>Perform the upgrade</strong> following the tool’s prompts and guidance.</li>
<li><strong>Analyze and reindex</strong> where recommended to rebuild statistics and indexes.</li>
<li><strong>Start the new service</strong> and test with your applications before decommissioning the old cluster.</li>
</ol>
<p class="muted">pg_upgrade is much faster but requires strict adherence to its checklist. Always keep backups and a tested rollback plan.</p>
</div>
</section>
<section class="section">
<h2>Post‑migration checks</h2>
<div class="card-grid">
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-check"></use></svg> Connectivity</h3>
<p>Connect locally and remotely, run critical queries, and verify performance against benchmarks.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-check"></use></svg> Extensions</h3>
<p>Upgrade or reinstall extensions as needed; confirm versions and availability.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-check"></use></svg> Maintenance</h3>
<p>Rebuild statistics and consider reindexing for large or critical tables when advised.</p>
</div>
</div>
</section>
<section class="section">
<h2>Troubleshooting — quick answers</h2>
<div class="card-grid">
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Service still running</h3>
<p>Stop the PostgreSQL Windows service and ensure no leftover processes are locking files before upgrading.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Permission denied</h3>
<p>Run tools with sufficient privileges and ensure the service account can access both old and new data directories.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Incompatible jump</h3>
<p>Some version jumps need intermediate steps. Review compatibility notes and consider dump/restore if pg_upgrade flags issues.</p>
</div>
</div>
</section>
<section class="section">
<h2>Related guides</h2>
<div class="card-grid">
<a class="card" href="https://postgre-sql.github.io/download-windows.html" style="text-decoration:none; color:inherit">
<h3>Download & Install</h3>
<p>Install the PostgreSQL server on Windows 10/11.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/configure-windows-service.html" style="text-decoration:none; color:inherit">
<h3>Configure Windows Service</h3>
<p>Startup type, service account, and recovery options.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/fix-path-issues.html" style="text-decoration:none; color:inherit">
<h3>Fix PATH Issues</h3>
<p>Resolve “psql is not recognized” fast.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/odbc-driver-x64-x86.html" style="text-decoration:none; color:inherit">
<h3>ODBC Drivers (x64/x86)</h3>
<p>Choose the right psqlODBC and set up a DSN.</p>
</a>
</div>
</section>
<section class="section">
<div class="disclaimer">
<p><strong>Disclaimer:</strong> This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.</p>
</div>
</section>
</main>
<div class="mobile-cta" aria-hidden="true">
<div class="inner">
<span>Need the PostgreSQL installer?</span>
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Download</span>
</a>
</div>
</div>
<footer>
<div class="wrap footer-inner">
<div>
<p class="muted">Author: Senior Web Developer & Technical Writer • Unofficial site</p>
<p class="muted">Last updated: <time id="lastUpdated" datetime="">--</time></p>
</div>
<div>
<p class="muted">Need help? Read <a href="https://postgre-sql.github.io/download-windows.html">Install guide</a> or <a href="https://postgre-sql.github.io/configure-windows-service.html">Service setup</a>.</p>
</div>
</div>
</footer>
<!-- Cookie banner -->
<div id="cookieBanner" class="cookie-banner" role="dialog" aria-live="polite" aria-label="Cookie consent">
<div class="cookie-content">
<div>
<strong>Cookies & analytics</strong>
<p class="muted" style="margin:6px 0 0">We use minimal analytics to improve this guide. Choose Accept to enable Google Analytics, or Decline to stay anonymous.</p>
</div>
<div class="cookie-actions">
<button class="btn btn-primary" id="cookieAccept">Accept</button>
<button class="btn btn-ghost" id="cookieDecline">Decline</button>
<button class="btn" id="cookieClose" aria-label="Close cookie banner"><svg width="16" height="16" aria-hidden="true"><use href="#icon-close"></use></svg> Close</button>
</div>
</div>
</div>
<script>
(function(){
const FILE_URL = 'https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe';
const FILE_NAME = 'postgresql-18.3-3-windows-x64.exe';
// Bind GA download events to all direct download anchors
function bindDownloadEvents(){
document.querySelectorAll('a[data-download-url]').forEach(a => {
a.addEventListener('click', function(){
try {
gtag('event','file_download', {
event_category: 'downloads',
event_label: a.getAttribute('data-download-file') || FILE_NAME,
file_url: a.getAttribute('data-download-url') || FILE_URL
});
} catch(e) {}
}, {passive:true});
});
}
// Cookie consent banner logic
const banner = document.getElementById('cookieBanner');
const btnAccept = document.getElementById('cookieAccept');
const btnDecline = document.getElementById('cookieDecline');
const btnClose = document.getElementById('cookieClose');
function showBanner(){ banner.style.display='block'; }
function hideBanner(){ banner.style.display='none'; }
function applyStoredConsent(){
const saved = localStorage.getItem('ga_consent');
if(saved === 'granted'){
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
} else if(saved === 'denied'){
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
} else {
const closed = sessionStorage.getItem('cookie_banner_closed');
if(!closed) showBanner();
}
}
btnAccept.addEventListener('click', function(){
localStorage.setItem('ga_consent','granted');
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
});
btnDecline.addEventListener('click', function(){
localStorage.setItem('ga_consent','denied');
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
});
btnClose.addEventListener('click', function(){
sessionStorage.setItem('cookie_banner_closed','1');
hideBanner();
});
// Update visible last updated and meta
const last = new Date(document.lastModified || '2026-05-01T13:06:51Z');
const lastISO = last.toISOString();
const lastEl = document.getElementById('lastUpdated');
if(lastEl){ lastEl.textContent = last.toLocaleDateString(undefined, {year:'numeric', month:'short', day:'2-digit'}); lastEl.setAttribute('datetime', lastISO); }
const metaLM = document.querySelector('meta[name="last-modified"]');
if(metaLM){ metaLM.setAttribute('content', lastISO); }
bindDownloadEvents();
applyStoredConsent();
})();
</script>
</body>
</html>