Class: PhilColumns::Migrator
- Inherits:
-
Object
- Object
- PhilColumns::Migrator
show all
- Includes:
- Output, WithBackend
- Defined in:
- lib/phil_columns/migrator.rb
Instance Method Summary
collapse
included
Methods included from Output
#confirm, included, #say, #say_error, #say_ok, #say_skipping, #write
Constructor Details
#initialize(config) ⇒ Migrator
Returns a new instance of Migrator.
7
8
9
10
|
# File 'lib/phil_columns/migrator.rb', line 7
def initialize( config )
@backend = PhilColumns::migrator_klass.new
@config = config
end
|
Instance Method Details
#clear_migrations_table ⇒ Object
12
13
14
15
|
# File 'lib/phil_columns/migrator.rb', line 12
def clear_migrations_table
raise( *error ) unless backend_responds?( :clear_migrations_table )
backend.send :clear_migrations_table
end
|
#down(version = 0) ⇒ Object
17
18
19
20
|
# File 'lib/phil_columns/migrator.rb', line 17
def down( version=0 )
raise( *error ) unless backend_responds?( :down )
backend.send :down, version
end
|
#drop_table(table) ⇒ Object
22
23
24
25
|
# File 'lib/phil_columns/migrator.rb', line 22
def drop_table( table )
raise( *error ) unless backend_responds?( :drop_table )
backend.send :drop_table, table
end
|
#drop_tables ⇒ Object
27
28
29
30
|
# File 'lib/phil_columns/migrator.rb', line 27
def drop_tables
raise( *error ) unless backend_responds?( :drop_tables )
backend.send :drop_tables
end
|
#latest_version ⇒ Object
32
33
34
35
|
# File 'lib/phil_columns/migrator.rb', line 32
def latest_version
raise( *error ) unless backend_responds?( :latest_version )
backend.send :latest_version
end
|
#load_schema ⇒ Object
37
38
39
40
|
# File 'lib/phil_columns/migrator.rb', line 37
def load_schema
raise( *error ) unless backend_responds?( :load_schema )
backend.send :load_schema
end
|
#mulligan ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/phil_columns/migrator.rb', line 42
def mulligan
if config.schema_unload_strategy == 'drop'
confirm "Dropping all tables ... ", :cyan do
drop_tables
clear_migrations_table
end
else
confirm "Migrating DB to version 0 ... ", :cyan do
down
end
end
if config.schema_load_strategy == 'load'
confirm "Loading schema ... ", :cyan do
load_schema
end
else
confirm "Migrating DB to latest version ... ", :cyan do
up
end
end
end
|
#tables ⇒ Object
65
66
67
68
|
# File 'lib/phil_columns/migrator.rb', line 65
def tables
raise( *error ) unless backend_responds?( :tables )
backend.send :tables
end
|
#up(version = nil) ⇒ Object
70
71
72
73
|
# File 'lib/phil_columns/migrator.rb', line 70
def up( version=nil )
raise( *error ) unless backend_responds?( :up )
backend.send :up, version
end
|