-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create warning event when postgres version is EOL.
- Loading branch information
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2021 - 2024 Crunchy Data Solutions, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package postgres | ||
|
||
import "time" | ||
|
||
// https://www.postgresql.org/support/versioning | ||
var finalReleaseDates = map[int]time.Time{ | ||
10: time.Date(2022, time.November+1, 10, 0, 0, 0, 0, time.UTC), | ||
11: time.Date(2023, time.November+1, +9, 0, 0, 0, 0, time.UTC), | ||
12: time.Date(2024, time.November+1, 14, 0, 0, 0, 0, time.UTC), | ||
13: time.Date(2025, time.November+1, 13, 0, 0, 0, 0, time.UTC), | ||
14: time.Date(2026, time.November+1, 12, 0, 0, 0, 0, time.UTC), | ||
15: time.Date(2027, time.November+1, 11, 0, 0, 0, 0, time.UTC), | ||
16: time.Date(2028, time.November+1, +9, 0, 0, 0, 0, time.UTC), | ||
17: time.Date(2029, time.November+1, +8, 0, 0, 0, 0, time.UTC), | ||
} | ||
|
||
// ReleaseIsFinal returns whether or not t is definitively past the final | ||
// scheduled release of a Postgres version. | ||
func ReleaseIsFinal(majorVersion int, t time.Time) bool { | ||
known, ok := finalReleaseDates[majorVersion] | ||
return ok && t.After(known) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 - 2024 Crunchy Data Solutions, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package postgres | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestReleaseIsFinal(t *testing.T) { | ||
// On November 4th, 2024, PG 10 and 11 were EOL and 12-17 were supported. | ||
testDate, err := time.Parse("2006-Jan-02", "2024-Nov-04") | ||
assert.NilError(t, err) | ||
assert.Check(t, ReleaseIsFinal(10, testDate)) | ||
assert.Check(t, ReleaseIsFinal(11, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(12, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(13, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(14, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(15, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(16, testDate)) | ||
assert.Check(t, !ReleaseIsFinal(17, testDate)) | ||
|
||
// On December 15th, 2024 we alert that PG 12 is EOL | ||
testDate = testDate.AddDate(0, 1, 11) | ||
assert.Check(t, ReleaseIsFinal(12, testDate)) | ||
|
||
// ReleaseIsFinal covers PG versions 10 and greater. Any version not covered | ||
// by the case statement in ReleaseIsFinal returns false | ||
assert.Check(t, !ReleaseIsFinal(1, testDate)) | ||
} |