simple_migrator 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/simple_migrator/migratable.rb +1 -1
- data/lib/simple_migrator/migrator.rb +5 -4
- data/lib/simple_migrator/version.rb +1 -1
- data/spec/migrator_spec.rb +19 -4
- 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: 71ac5f22636b7fc9b4ecc37945d3e713ed6095dc
|
4
|
+
data.tar.gz: 3b3aa758fe366adf86593bb980eec6c2497bb1cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3731c2a652d08cb1df200708df0530dac35274529e45003f197476bcc36d2fa50c6fc0d46554cf509930e2ee8012e46ed0ba2935271a274b97ea6e0569ad18e8
|
7
|
+
data.tar.gz: 6cba75f0ac1f2474b24e9436555f2d0f6d3cca6fb8fde9266255baf690ae08cf75e3b518cd03c6c8fad23840ab611d81af01055682be60dae16ce900d909554f
|
@@ -22,7 +22,7 @@ module SimpleMigrator
|
|
22
22
|
raise NoMigratorError, "`migrate!` called without a migrator.\nEither provide a migrator or define a `migrator` method"
|
23
23
|
end
|
24
24
|
|
25
|
-
def rebind_proc(proc)
|
25
|
+
def rebind_proc(proc)
|
26
26
|
Proc.new do |db|
|
27
27
|
instance_exec(db, &proc)
|
28
28
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module SimpleMigrator
|
2
2
|
class Migrator
|
3
|
-
def initialize(connection)
|
3
|
+
def initialize(connection, migration_table_name = nil)
|
4
|
+
@table_name = migration_table_name
|
4
5
|
@connection = connection
|
5
6
|
ensure_migration_table!
|
6
7
|
end
|
@@ -22,12 +23,12 @@ module SimpleMigrator
|
|
22
23
|
connection[table_name]
|
23
24
|
end
|
24
25
|
|
25
|
-
def self.
|
26
|
-
:
|
26
|
+
def self.default_table_name
|
27
|
+
:simple_migrator_schema_migrations
|
27
28
|
end
|
28
29
|
|
29
30
|
def table_name
|
30
|
-
self.class.
|
31
|
+
@table_name || self.class.default_table_name
|
31
32
|
end
|
32
33
|
|
33
34
|
private
|
data/spec/migrator_spec.rb
CHANGED
@@ -7,11 +7,26 @@ module SimpleMigrator
|
|
7
7
|
|
8
8
|
describe "#initialize" do
|
9
9
|
context "when no prior migration table exists" do
|
10
|
-
|
11
|
-
|
10
|
+
context "when given no explicit table name" do
|
11
|
+
before do
|
12
|
+
Migrator.new(connection)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "creates one" do
|
16
|
+
expect(connection.tables).to include(Migrator.default_table_name)
|
17
|
+
end
|
12
18
|
end
|
13
|
-
|
14
|
-
|
19
|
+
|
20
|
+
context "when given an explicit table name" do
|
21
|
+
context "when given a table name" do
|
22
|
+
let(:table_name) { :foobar }
|
23
|
+
before do
|
24
|
+
Migrator.new(connection, table_name)
|
25
|
+
end
|
26
|
+
it "creates a table with that name" do
|
27
|
+
expect(connection.tables).to include(table_name)
|
28
|
+
end
|
29
|
+
end
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesper Josefsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|