6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/jungle_path/migration/migration.rb', line 6
def self.run schema_module, db, version=nil
Sequel.extension :migration
db.base.loggers << Logger.new($stdout)
db.base.identifier_input_method = :downcase
version = schema_module.version unless version
path = schema_module.migrations_path
display_version = version || "'latest available'"
puts "Migrating database to version: #{display_version} on #{db.config.host}.#{db.config.name}:#{db.config.port}."
puts "Using migration files at: #{path}"
if JunglePath::DBAccess::Meta::DB.exists? db.config if version
Sequel::Migrator.run(db.base, path, target: version)
else
Sequel::Migrator.run(db.base, path)
end
else
puts "Database does not exist, run zcreatedb.rb and then zbootstrapdata.rb..."
puts "Write some code to create the schema_info table with integer column version and set the version! This table should always have only one row."
end
end
|