This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
/
runner.rb
71 lines (63 loc) · 1.53 KB
/
runner.rb
1
2
3
4
5
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'dm-migrations/runner/class_methods'
require 'set'
module DataMapper
module Migrations
module Runner
#
# Registers a new migration namespace.
#
# @param [Module] base
# The namespace that will contain migrations.
#
# @since 1.0.1
#
def self.included(base)
if base == Kernel
base.send :include, ClassMethods
else
base.send :extend, ClassMethods
end
Runner.migration_namespaces << base
end
#
# The registered migration namespaces.
#
# @return [Set<Module>]
# The registered modules that contain migrations.
#
# @since 1.0.1
#
def Runner.migration_namespaces
@dm_migration_namespaces ||= Set[]
end
#
# Migrates all migration namespaces upwards.
#
# @return [true]
# All migration namespaces were successfully migrated up.
#
# @since 1.0.1
#
def Runner.migrate_up!
Runner.migration_namespaces.each do |migration_namespace|
migration_namespace.migrate_up!
end
true
end
#
# Migrates all migration namespaces downwards.
#
# @return [true]
# All migration namespaces were successfully migrated down.
#
# @since 1.0.1
#
def Runner.migrate_down!
Runner.migration_namespaces.reverse_each do |migration_namespace|
migration_namespace.migrate_down!
end
true
end
end
end
end