# # add_file "tests/t_migrate_broken_schema.at" # # patch "ChangeLog" # from [6ee383adec65fed9cc5cd995423161569742af8b] # to [c6dac5393fae44a9c1eba50165891f5daf0402ed] # # patch "schema_migration.cc" # from [321533da055eb96c09cfb11ae0215aa0c7e41e3a] # to [b936e624803d0d0aceb742ca46d5f98b28ce9beb] # # patch "tests/t_migrate_broken_schema.at" # from [] # to [330c2d86dbacfc63b6491e1265cf9c252074196d] # # patch "testsuite.at" # from [0053f6d5ae281707c89693dbf4e0c6b3c4a8b61c] # to [1c811c77a15a6f2e9596cbd748a52b7a38c4699c] # =============================================== --- ChangeLog 6ee383adec65fed9cc5cd995423161569742af8b +++ ChangeLog c6dac5393fae44a9c1eba50165891f5daf0402ed @@ -1,5 +1,11 @@ 2005-07-19 Nathaniel Smith + * schema_migration.cc (migrator::migrate): Add a check for schemas + that are just... wrong. + * tests/t_migrate_broken_schema.at: New test. + +2005-07-19 Nathaniel Smith + * netcmd.cc (read): Make the bad HMAC error message clearer. 2005-07-18 Nathaniel Smith =============================================== --- schema_migration.cc 321533da055eb96c09cfb11ae0215aa0c7e41e3a +++ schema_migration.cc b936e624803d0d0aceb742ca46d5f98b28ce9beb @@ -260,6 +260,10 @@ } else { + // if we didn't do anything, make sure that it's because we were + // already up to date. + E(init == target_id, + F("database schema %s is unknown; cannot perform migration") % init); // We really want 'db migrate' on an up-to-date schema to be a no-op // (no vacuum or anything, even), so that automated scripts can fire // one off optimistically and not have to worry about getting their =============================================== --- tests/t_migrate_broken_schema.at +++ tests/t_migrate_broken_schema.at 330c2d86dbacfc63b6491e1265cf9c252074196d @@ -0,0 +1,10 @@ +AT_SETUP([db migrate on bad schema]) +MONOTONE_SETUP + +AT_CHECK(MONOTONE db migrate, [], [ignore], [ignore]) + +AT_CHECK(MONOTONE db execute 'CREATE TABLE foo (bar primary key, baz not null)', [], [ignore], [ignore]) + +AT_CHECK(MONOTONE db migrate, [1], [ignore], [ignore]) + +AT_CLEANUP =============================================== --- testsuite.at 0053f6d5ae281707c89693dbf4e0c6b3c4a8b61c +++ testsuite.at 1c811c77a15a6f2e9596cbd748a52b7a38c4699c @@ -674,3 +674,4 @@ m4_include(tests/t_restricted_diff_unchanged.at) m4_include(tests/t_selector_globbing.at) m4_include(tests/t_diff_external.at) +m4_include(tests/t_migrate_broken_schema.at)