@@ -231,6 +231,12 @@ static void check_db_format(properties_t const &properties, options_t *options)
231231{
232232 auto const format = properties.get_int (" db_format" , -1 );
233233
234+ if (format == 1 ) {
235+ throw std::runtime_error{
236+ " Old database format detected. This version of osm2pgsql can not "
237+ " read this any more. Downgrade osm2pgsql or reimport database." };
238+ }
239+
234240 if (format != 2 ) {
235241 throw fmt_error (" Unknown db_format '{}' in properties." , format);
236242 }
@@ -303,23 +309,6 @@ static void check_and_update_properties(properties_t *properties,
303309 check_and_update_style_file (properties, options);
304310}
305311
306- // If we are in append mode and the middle nodes table isn't there, it probably
307- // means we used a flat node store when we created this database. Check for
308- // that and stop if it looks like we are missing the node location store
309- // option. (This function is only used in legacy systems which don't have the
310- // properties stored in the database.)
311- static void check_for_nodes_table (options_t const &options)
312- {
313- if (!options.flat_node_file .empty ()) {
314- return ;
315- }
316-
317- if (!has_table (options.middle_dbschema , options.prefix + " _nodes" )) {
318- throw std::runtime_error{" You seem to not have a nodes table. Did "
319- " you forget the --flat-nodes option?" };
320- }
321- }
322-
323312static void set_option_defaults (options_t *options)
324313{
325314 if (options->output_backend .empty ()) {
@@ -360,13 +349,14 @@ int main(int argc, char *argv[])
360349 properties_t properties{options.connection_params ,
361350 options.middle_dbschema };
362351 if (options.append ) {
363- if (properties.load ()) {
364- check_and_update_properties (&properties, &options);
365- } else {
366- set_option_defaults (&options);
367- check_for_nodes_table (options);
352+ if (!properties.load ()) {
353+ throw std::runtime_error{
354+ " Did not find table 'osm2pgsql_properties' in database. "
355+ " Database too old? Wrong schema?" };
368356 }
369357
358+ check_and_update_properties (&properties, &options);
359+
370360 auto const finfo = run (options);
371361
372362 if (finfo.last_timestamp .valid ()) {
0 commit comments