redshift_simple_migrator 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redshift_simple_migrator.rb +11 -5
- data/lib/redshift_simple_migrator/configuration.rb +2 -0
- data/lib/redshift_simple_migrator/connection.rb +1 -1
- data/lib/redshift_simple_migrator/migration.rb +64 -1
- data/lib/redshift_simple_migrator/migrator.rb +2 -2
- data/lib/redshift_simple_migrator/railtie.rb +1 -0
- data/lib/redshift_simple_migrator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df47cc4f31ba3e1849b1d60811a077d2d50e9c1f
|
4
|
+
data.tar.gz: 7f406e403126d9d1232486288e13210467c3b358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e7a213eb0545a4bee8188d8349d87a6092a529f060e03f2678e004e9b04ddd840ceb52a127fc1a8eda41eb79b200e054953b53248b1419762ff3b2c83308bbe
|
7
|
+
data.tar.gz: dbb157f09cf92751e68a54f7ce52e3ad65bf03207799d69d7dbc0378b7bfee3f76f37b44fc183cc2266f5eea29b90b4a45b0a4ad8f9f4e7c24210f7bee111ff1
|
@@ -1,12 +1,18 @@
|
|
1
1
|
require "redshift_simple_migrator/version"
|
2
2
|
|
3
3
|
module RedshiftSimpleMigrator
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
def config
|
6
|
+
RedshiftSimpleMigrator::Configuration.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
def configure
|
10
|
+
yield self.config
|
11
|
+
end
|
7
12
|
|
8
|
-
|
9
|
-
|
13
|
+
def logger
|
14
|
+
config.logger
|
15
|
+
end
|
10
16
|
end
|
11
17
|
end
|
12
18
|
|
@@ -1,12 +1,54 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'active_support/callbacks'
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
|
1
5
|
module RedshiftSimpleMigrator
|
2
6
|
class Migration
|
7
|
+
include ActiveSupport::Callbacks
|
8
|
+
define_callbacks :up, :down, :execute
|
9
|
+
|
10
|
+
set_callback :up, :before, :display_migration_up_start
|
11
|
+
set_callback :up, :after, :display_migration_up_finish
|
12
|
+
set_callback :down, :before, :display_migration_down_start
|
13
|
+
set_callback :down, :after, :display_migration_down_finish
|
14
|
+
|
15
|
+
module RunCallbacksWrapper
|
16
|
+
def up
|
17
|
+
run_callbacks :up do
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def down
|
23
|
+
run_callbacks :down do
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def exec(*args)
|
29
|
+
log_sql(args[0])
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute(*args)
|
34
|
+
log_sql(args[0])
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.inherited(subclass)
|
40
|
+
subclass.class_eval do
|
41
|
+
prepend RunCallbacksWrapper
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
3
45
|
attr_reader :connection, :version
|
4
46
|
|
5
47
|
delegate \
|
6
48
|
:exec,
|
7
49
|
:escape,
|
8
50
|
:escape_string,
|
9
|
-
:
|
51
|
+
:quote_ident,
|
10
52
|
:escape_literal,
|
11
53
|
to: :connection
|
12
54
|
alias :execute :exec
|
@@ -23,5 +65,26 @@ module RedshiftSimpleMigrator
|
|
23
65
|
def down
|
24
66
|
raise NotImplementedError
|
25
67
|
end
|
68
|
+
|
69
|
+
def display_migration_up_start
|
70
|
+
puts "== #{self.class.to_s} up migrating =="
|
71
|
+
end
|
72
|
+
|
73
|
+
def display_migration_up_finish
|
74
|
+
puts "== #{self.class.to_s} up migrated =="
|
75
|
+
end
|
76
|
+
|
77
|
+
def display_migration_down_start
|
78
|
+
puts "== #{self.class.to_s} down migrating =="
|
79
|
+
end
|
80
|
+
|
81
|
+
def display_migration_down_finish
|
82
|
+
puts "== #{self.class.to_s} down migrated =="
|
83
|
+
end
|
84
|
+
|
85
|
+
def log_sql(sql)
|
86
|
+
puts "-- Execute --\n#{sql}"
|
87
|
+
RedshiftSimpleMigrator.logger.try(:info, "SQL (RedshiftSimpleMigrator) #{sql}")
|
88
|
+
end
|
26
89
|
end
|
27
90
|
end
|
@@ -13,7 +13,7 @@ module RedshiftSimpleMigrator
|
|
13
13
|
@connection = Connection.new
|
14
14
|
@migrations_path = config.migrations_path
|
15
15
|
@schema_migrations_table_name =
|
16
|
-
@connection.
|
16
|
+
@connection.quote_ident(config.schema_migrations_table_name)
|
17
17
|
|
18
18
|
@current_version_is_loaded = nil
|
19
19
|
@current_migrations = nil
|
@@ -24,7 +24,7 @@ module RedshiftSimpleMigrator
|
|
24
24
|
|
25
25
|
migrations = Dir.entries(migrations_path).map do |name|
|
26
26
|
if match = MIGRATION_FILE_PATTERN.match(name)
|
27
|
-
|
27
|
+
require File.expand_path(File.join(migrations_path, name))
|
28
28
|
migration_class = match[:migration_name].camelcase.constantize
|
29
29
|
migration_class.new(connection, match[:version].to_i)
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redshift_simple_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|