@@ -182,38 +182,31 @@ func terminateContainer(ctx context.Context, t *testing.T, container testcontain
182182
183183func insertTestData (ctx context.Context , conn string ) error {
184184 db , err := pgx .Connect (ctx , conn )
185+
185186 if err != nil {
186187 return fmt .Errorf ("unable to connect to database: %w" , err )
187188 }
188189 defer db .Close (ctx )
189190
190- // TODO: Disabled since partitioning is disabled for now (see)
191- // // Create required partitions for testData
192- // //nolint:misspell
193- // partitions := `
194- // create table search_index_addres partition of search_index
195- // for values in ('adres');
196- // -- partition by list(collection_version);
197- // create table search_index_weg partition of search_index
198- // for values in ('weg');
199- // -- partition by list(collection_version);
200- // `
201- //
202- // _, err = db.Exec(ctx, partitions)
203- // if err != nil {
204- // log.Printf("Error creating partitions: %v\n", err)
205- // }
206-
207- // language=postgresql
191+ var partitions = [3 ]string {"addresses" , "roads" }
192+
193+ for i := range partitions {
194+ partition := `create table if not exists search_index_` + partitions [i ] + ` partition of search_index for values in ('` + partitions [i ] + `');`
195+ _ , err = db .Exec (ctx , partition )
196+ if err != nil {
197+ log .Printf ("Error creating partition: %s Error: %v\n " , partitions [i ], err )
198+ }
199+ }
200+
208201 testData := `
209202 insert into search_index(feature_id, collection_id, collection_version, display_name, suggest, geometry_type, bbox)
210203 values
211- ('408f5e13', 'adres ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
212- ('408f5e13', 'adres ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
213- ('408f5e13', 'adres ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
214- ('408f5e13', 'adres ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
215- ('1e99b620', 'weg ' , 2, 'Daendelsweg, 7315AJ Apeldoorn' , 'Daendelsweg 4A, 7315AJ Apeldoorn', 'LINESTRING', 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
216- ('1e99b620', 'weg ' , 2, 'Daendelsweg, 7315AJ Apeldoorn' , 'Daendelsweg 4A, 7315AJ Apeldoorn', 'LINESTRING', 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))');
204+ ('408f5e13', 'addresses ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
205+ ('408f5e13', 'addresses ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
206+ ('408f5e13', 'addresses ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
207+ ('408f5e13', 'addresses ', 1, 'Daendelsweg 4A, 7315AJ Apeldoorn', 'Daendelsweg 4A, 7315AJ Apeldoorn', 'POINT' , 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
208+ ('1e99b620', 'roads ' , 2, 'Daendelsweg, 7315AJ Apeldoorn' , 'Daendelsweg 4A, 7315AJ Apeldoorn', 'LINESTRING', 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))'),
209+ ('1e99b620', 'roads ' , 2, 'Daendelsweg, 7315AJ Apeldoorn' , 'Daendelsweg 4A, 7315AJ Apeldoorn', 'LINESTRING', 'POLYGON((-180 -90, -180 90, 180 90, 180 -90, -180 -90))');
217210 `
218211
219212 _ , err = db .Exec (ctx , testData )
0 commit comments