1010 let
1111 pname = extension_name ;
1212 inherit ( pkgs ) lib ;
13- # Special case for timescaledb-apache: only test with PostgreSQL 15
14- isTimescaledb = extension_name == "timescaledb-apache" ;
1513 installedExtension =
1614 postgresMajorVersion : self . packages . ${ pkgs . system } . "psql_${ postgresMajorVersion } /exts/${ pname } -all" ;
1715 versions = postgresqlMajorVersion : ( installedExtension postgresqlMajorVersion ) . versions ;
4644 in
4745 pkg ;
4846 psql_15 = postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_15 ;
49- psql_17 =
50- if isTimescaledb then null else postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_17 ;
47+ psql_17 = postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_17 ;
5148 in
5249 self . inputs . nixpkgs . lib . nixos . runTest {
5350 name = pname ;
8380
8481 networking . firewall . allowedTCPPorts = [ config . services . postgresql . settings . port ] ;
8582
86- specialisation = lib . optionalAttrs ( ! isTimescaledb ) {
87- postgresql17 . configuration = {
88- services . postgresql = {
89- package = lib . mkForce psql_17 ;
90- } ;
83+ specialisation . postgresql17 . configuration = {
84+ services . postgresql = {
85+ package = lib . mkForce psql_17 ;
86+ } ;
9187
92- systemd . services . postgresql-migrate = {
93- serviceConfig = {
94- Type = "oneshot" ;
95- RemainAfterExit = true ;
96- User = "postgres" ;
97- Group = "postgres" ;
98- StateDirectory = "postgresql" ;
99- WorkingDirectory = "${ builtins . dirOf config . services . postgresql . dataDir } " ;
100- } ;
101- script =
102- let
103- oldPostgresql = psql_15 ;
104- newPostgresql = psql_17 ;
105- oldDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ oldPostgresql . psqlSchema } " ;
106- newDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ newPostgresql . psqlSchema } " ;
107- in
108- ''
109- if [[ ! -d ${ newDataDir } ]]; then
110- install -d -m 0700 -o postgres -g postgres "${ newDataDir } "
111- ${ newPostgresql } /bin/initdb -D "${ newDataDir } "
112- ${ newPostgresql } /bin/pg_upgrade --old-datadir "${ oldDataDir } " --new-datadir "${ newDataDir } " \
113- --old-bindir "${ oldPostgresql } /bin" --new-bindir "${ newPostgresql } /bin"
114- else
115- echo "${ newDataDir } already exists"
116- fi
117- '' ;
88+ systemd . services . postgresql-migrate = {
89+ serviceConfig = {
90+ Type = "oneshot" ;
91+ RemainAfterExit = true ;
92+ User = "postgres" ;
93+ Group = "postgres" ;
94+ StateDirectory = "postgresql" ;
95+ WorkingDirectory = "${ builtins . dirOf config . services . postgresql . dataDir } " ;
11896 } ;
97+ script =
98+ let
99+ oldPostgresql = psql_15 ;
100+ newPostgresql = psql_17 ;
101+ oldDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ oldPostgresql . psqlSchema } " ;
102+ newDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ newPostgresql . psqlSchema } " ;
103+ in
104+ ''
105+ if [[ ! -d ${ newDataDir } ]]; then
106+ install -d -m 0700 -o postgres -g postgres "${ newDataDir } "
107+ ${ newPostgresql } /bin/initdb -D "${ newDataDir } "
108+ ${ newPostgresql } /bin/pg_upgrade --old-datadir "${ oldDataDir } " --new-datadir "${ newDataDir } " \
109+ --old-bindir "${ oldPostgresql } /bin" --new-bindir "${ newPostgresql } /bin"
110+ else
111+ echo "${ newDataDir } already exists"
112+ fi
113+ '' ;
114+ } ;
119115
120- systemd . services . postgresql = {
121- after = [ "postgresql-migrate.service" ] ;
122- requires = [ "postgresql-migrate.service" ] ;
123- } ;
116+ systemd . services . postgresql = {
117+ after = [ "postgresql-migrate.service" ] ;
118+ requires = [ "postgresql-migrate.service" ] ;
124119 } ;
125120 } ;
126121 } ;
132127 ''
133128 versions = {
134129 "15": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "15" ) ) } ],
135- ${
136- if isTimescaledb then
137- ""
138- else
139- ''"17": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "17" ) ) } ],''
140- }
130+ "17": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "17" ) ) } ],
141131 }
142132 extension_name = "${ pname } "
143133 support_upgrade = True
@@ -166,22 +156,16 @@ let
166156 with subtest("Test switch_${ pname } _version"):
167157 test.check_switch_extension_with_background_worker(Path("${ psql_15 } /lib/${ pname } .so"), "15")
168158
169- ${
170- if isTimescaledb then
171- ""
172- else
173- ''
174- with subtest("switch to postgresql 17"):
175- server.succeed(
176- f"{pg17_configuration}/bin/switch-to-configuration test >&2"
177- )
159+ with subtest("switch to postgresql 17"):
160+ server.succeed(
161+ f"{pg17_configuration}/bin/switch-to-configuration test >&2"
162+ )
178163
179- with subtest("Check last version of the extension after upgrade"):
180- test.assert_version_matches(last_version)
164+ with subtest("Check last version of the extension after upgrade"):
165+ test.assert_version_matches(last_version)
181166
182- with subtest("Check upgrade path with postgresql 17"):
183- test.check_upgrade_path("17")''
184- }
167+ with subtest("Check upgrade path with postgresql 17"):
168+ test.check_upgrade_path("17")
185169 '' ;
186170 } ;
187171in
@@ -202,7 +186,7 @@ builtins.listToAttrs (
202186 "index_advisor"
203187 "pg_cron"
204188 "pg_net"
205- "timescaledb-apache "
189+ "timescaledb"
206190 "vector"
207191 "wrappers"
208192 ]
0 commit comments