251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
# 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 <<~EOM
=======================================================================
Important migration issue
=======================================================================
Hello!
It appears that you are upgrading ArchivesSpace from version 1.4.2 or prior. To
complete this upgrade, there are some additional steps to follow.
The 1.5 series of ArchivesSpace introduced a new data model for containers,
along with a compatibility layer to provide a seamless transition between the
old and new container models. In ArchivesSpace version 2.1, this compatibility
layer was removed in the interest of long-term maintainability and system
performance.
To upgrade your ArchivesSpace installation, you will first need to upgrade to
version 2.0.1. This will upgrade your containers to the new model and clear the
path for future upgrades. Once you have done this, you can upgrade to the
latest ArchivesSpace version as normal.
For more information on upgrading to ArchivesSpace 2.0.1, please see the upgrade
guide:
https://archivesspace.github.io/tech-docs/administration/upgrading.html
The upgrade guide for version 1.5.0 also contains specific instructions for
the container upgrade that you will be performing, and the steps in this guide
apply equally to version 2.0.1. You can find that guide here:
https://github.com/archivesspace/archivesspace/blob/master/UPGRADING_1.5.0.md
=======================================================================
EOM
raise ContainerMigrationError.new
end
end
def self.nuke_database(db)
$db_type = db.database_type
if $db_type == :mysql
db.run('SET foreign_key_checks = 0;')
db.drop_table?(*db.tables)
db.run('SET foreign_key_checks = 1;')
else
PLUGIN_MIGRATIONS.reverse.each { |plugin| Sequel::Migrator.run(db, PLUGIN_MIGRATION_DIRS[plugin],
:table => "#{plugin}_schema_info", :target => 0) }
Sequel::Migrator.run(db, MIGRATIONS_DIR, :target => 0)
end
end
def self.needs_updating?(db)
$db_type = db.database_type
return true unless Sequel::Migrator.is_current?(db, MIGRATIONS_DIR)
PLUGIN_MIGRATIONS.each { |plugin| return true unless Sequel::Migrator.is_current?(db, PLUGIN_MIGRATIONS_DIR[plugin],
:table => "#{plugin}_schema_info") }
return false
end
def self.latest_migration_number(db)
migration_numbers = Dir.entries(MIGRATIONS_DIR).map {|e|
if e =~ Sequel::Migrator::MIGRATION_FILE_PATTERN
Integer($1, 10)
end
}.compact
if migration_numbers.empty?
0
else
migration_numbers.max
end
end
end
|