16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ree_lib/packages/ree_migrator/package/ree_migrator/functions/apply_migration.rb', line 16
def call(connection, migration_path, type)
if !File.exist?(migration_path)
raise ArgumentError.new("file not found: #{migration_path}")
end
logger.info("Applying migration: #{migration_path}")
load(migration_path)
migration = Sequel::Migration.descendants.last
migration_name = File.basename(migration_path)
connection.instance_eval(&migration.up)
connection[:migrations].insert({
filename: migration_name,
type: type.to_s,
created_at: now
})
nil
end
|