251
252
253
254
255
256
257
258
259
260
261
|
# File 'common/db/db_migrator.rb', line 251
def self.fail_if_managed_container_migration_needed!(db)
if db.tables.empty?
current_version = 0
else
current_version = db[:schema_info].first[:version]
end
if current_version && current_version > 0 && current_version < CONTAINER_MIGRATION_NUMBER
$stderr.puts "\n =======================================================================\n Important migration issue\n =======================================================================\n\n Hello!\n\n It appears that you are upgrading ArchivesSpace from version 1.4.2 or prior. To\n complete this upgrade, there are some additional steps to follow.\n\n The 1.5 series of ArchivesSpace introduced a new data model for containers,\n along with a compatibility layer to provide a seamless transition between the\n old and new container models. In ArchivesSpace version 2.1, this compatibility\n layer was removed in the interest of long-term maintainability and system\n performance.\n\n To upgrade your ArchivesSpace installation, you will first need to upgrade to\n version 2.0.1. This will upgrade your containers to the new model and clear the\n path for future upgrades. Once you have done this, you can upgrade to the\n latest ArchivesSpace version as normal.\n\n For more information on upgrading to ArchivesSpace 2.0.1, please see the upgrade\n guide:\n\n https://archivesspace.github.io/tech-docs/administration/upgrading.html\n\n The upgrade guide for version 1.5.0 also contains specific instructions for\n the container upgrade that you will be performing, and the steps in this guide\n apply equally to version 2.0.1. You can find that guide here:\n\n https://github.com/archivesspace/archivesspace/blob/master/UPGRADING_1.5.0.md\n\n =======================================================================\n\n EOM\n\n raise ContainerMigrationError.new\n end\n end\n\n\n def self.nuke_database(db)\n $db_type = db.database_type\n\n if $db_type == :mysql\n db.run('SET foreign_key_checks = 0;')\n db.drop_table?(*db.tables)\n db.run('SET foreign_key_checks = 1;')\n else\n PLUGIN_MIGRATIONS.reverse.each { |plugin| Sequel::Migrator.run(db, PLUGIN_MIGRATION_DIRS[plugin],\n :table => \"\#{plugin}_schema_info\", :target => 0) }\n Sequel::Migrator.run(db, MIGRATIONS_DIR, :target => 0)\n end\n end\n\n def self.needs_updating?(db)\n $db_type = db.database_type\n return true unless Sequel::Migrator.is_current?(db, MIGRATIONS_DIR)\n PLUGIN_MIGRATIONS.each { |plugin| return true unless Sequel::Migrator.is_current?(db, PLUGIN_MIGRATIONS_DIR[plugin],\n :table => \"\#{plugin}_schema_info\") }\n return false\n end\n\n def self.latest_migration_number(db)\n migration_numbers = Dir.entries(MIGRATIONS_DIR).map {|e|\n if e =~ Sequel::Migrator::MIGRATION_FILE_PATTERN\n # $1 is the migration number (e.g. '075')\n Integer($1, 10)\n end\n }.compact\n\n if migration_numbers.empty?\n 0\n else\n migration_numbers.max\n end\n end\nend\n"
|