standalone_migrations 2.1.4 → 2.1.5
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 +8 -8
- data/.travis.yml +1 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.markdown +13 -0
- data/Rakefile +6 -0
- data/VERSION +1 -1
- data/lib/standalone_migrations.rb +1 -0
- data/lib/standalone_migrations/callbacks.rb +13 -0
- data/lib/standalone_migrations/configurator.rb +3 -3
- data/lib/standalone_migrations/tasks/connection.rake +1 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/standalone_migrations/callbacks_spec.rb +48 -0
- data/spec/standalone_migrations/configurator_spec.rb +7 -0
- data/spec/standalone_migrations_spec.rb +27 -6
- data/standalone_migrations.gemspec +5 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWM3OTBhMzM0MDNhYmM1M2ZkZDIzNzQ1YjdjNGU2ZjgzNjQ1Y2M1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDQwZTMwZjA0NGE3ODg2NWExN2MxZjYyZWZhODY1YTk0NzM3YzcwZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDY0YTU2MmI4MDcwMzNkMGUwYTg3YTQwNWUzZGFiZGM4Y2Y5ZDY0NDhmNjM5
|
10
|
+
MjQ1N2M2MWY4NGU4MWZlMzY0NDNlNmNmOGY5ZjQxMWQ1MzY1NTllZWI3MDMz
|
11
|
+
MDE2Y2NiNjg0ZDFkOGM2NTIwYjNiNzk3MGVlNmViMGUyODEzNDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDgzOTMzODhlY2NiMDlkZWE4YzU5YTY4Y2Y3NzU1NDM4ZjE3ZDljM2FmYzJj
|
14
|
+
NjhlODFjNzY4NjQ0NjhiYmE0M2UxNGFlMmUxYmY5Y2FiYWYxZDJmZmE2Nzcy
|
15
|
+
YmY1YWEwNTdhNDdjNmM1OWE3OWFhNjcxMWMzZWRjM2Y4ZTYxMDk=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -107,6 +107,18 @@ config:
|
|
107
107
|
These are the configurable options available. You can omit any of
|
108
108
|
the keys and Standalone Migrations will assume the default values.
|
109
109
|
|
110
|
+
### on_loaded callbacks
|
111
|
+
|
112
|
+
If you would like to use an external library such as [foreigner](https://github.com/matthuhiggins/foreigner) with standalone migrations, you can add the following to your `Rakefile`:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
require 'foreigner'
|
116
|
+
|
117
|
+
StandaloneMigrations.on_load do
|
118
|
+
Foreigner.load
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
110
122
|
###Multiple database support
|
111
123
|
|
112
124
|
####Structure
|
@@ -248,5 +260,6 @@ Contributors
|
|
248
260
|
- [Koen Punt](http://www.koen.pt/)
|
249
261
|
- [Parker Moore](http://www.parkermoore.de/)
|
250
262
|
- [Marcell Jusztin](http://www.morcmarc.com)
|
263
|
+
- [Eric Hayes](http://ejhay.es)
|
251
264
|
|
252
265
|
This work is originally based on [Lincoln Stoll's blog post](http://lstoll.net/2008/04/stand-alone-activerecord-migrations/) and [David Welton's post](http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails).
|
data/Rakefile
CHANGED
@@ -19,6 +19,12 @@ namespace :specs do
|
|
19
19
|
t.pattern = "spec/standalone_migrations/**/*_spec.rb"
|
20
20
|
end
|
21
21
|
|
22
|
+
desc "run all specs for travis"
|
23
|
+
RSpec::Core::RakeTask.new "travis" do |t|
|
24
|
+
t.pattern = "spec/**/*_spec.rb"
|
25
|
+
t.rspec_opts = "--tag ~@travis_error"
|
26
|
+
end
|
27
|
+
|
22
28
|
desc "run all specs including those which uses database"
|
23
29
|
task :all => [:default, :nodb]
|
24
30
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
@@ -7,6 +7,7 @@ require "active_record"
|
|
7
7
|
|
8
8
|
require "standalone_migrations/configurator"
|
9
9
|
require "standalone_migrations/generator"
|
10
|
+
require "standalone_migrations/callbacks"
|
10
11
|
|
11
12
|
railtie_app_path = "#{lib_path}/standalone_migrations/minimal_railtie_config"
|
12
13
|
APP_PATH = File.expand_path(railtie_app_path, __FILE__)
|
@@ -78,9 +78,9 @@ module StandaloneMigrations
|
|
78
78
|
config = YAML.load( ERB.new(IO.read(configuration_file)).result )
|
79
79
|
{
|
80
80
|
:config => config["config"] ? config["config"]["database"] : defaults[:config],
|
81
|
-
:migrate_dir => config["db"]
|
82
|
-
:seeds => config["db"]
|
83
|
-
:schema => config["db"]
|
81
|
+
:migrate_dir => (config["db"] || {})["migrate"] || defaults[:migrate_dir],
|
82
|
+
:seeds => (config["db"] || {})["seeds"] || defaults[:seeds],
|
83
|
+
:schema => (config["db"] || {})["schema"] || defaults[:schema]
|
84
84
|
}
|
85
85
|
end
|
86
86
|
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module StandaloneMigrations
|
4
|
+
|
5
|
+
describe "Callbacks" do
|
6
|
+
|
7
|
+
describe ".on_loaded" do
|
8
|
+
|
9
|
+
it "responds to on_loaded" do
|
10
|
+
StandaloneMigrations.should respond_to :on_loaded
|
11
|
+
end
|
12
|
+
|
13
|
+
it "responds to run_on_load_callbacks" do
|
14
|
+
StandaloneMigrations.should respond_to :run_on_load_callbacks
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can pass a block do on_loaded" do
|
18
|
+
callback_was_called = false
|
19
|
+
|
20
|
+
StandaloneMigrations.on_loaded do
|
21
|
+
callback_was_called = true
|
22
|
+
end
|
23
|
+
|
24
|
+
# invoke the callbacks
|
25
|
+
StandaloneMigrations.run_on_load_callbacks
|
26
|
+
|
27
|
+
callback_was_called.should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can pass multiple blocks to on_loaded" do
|
31
|
+
callback_count = 0
|
32
|
+
|
33
|
+
for i in 1..4
|
34
|
+
StandaloneMigrations.on_loaded do
|
35
|
+
callback_count += 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
StandaloneMigrations.run_on_load_callbacks
|
40
|
+
|
41
|
+
callback_count.should == 4
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -216,6 +216,9 @@ module StandaloneMigrations
|
|
216
216
|
{
|
217
217
|
"config" => {
|
218
218
|
"database" => "file/config/database.yml"
|
219
|
+
},
|
220
|
+
"db" => {
|
221
|
+
"seeds" => "file/db/seeds.rb"
|
219
222
|
}
|
220
223
|
}
|
221
224
|
end
|
@@ -228,6 +231,10 @@ module StandaloneMigrations
|
|
228
231
|
configurator.config.should == yaml_hash["config"]["database"]
|
229
232
|
end
|
230
233
|
|
234
|
+
it "use custom config value from partial configuration" do
|
235
|
+
configurator.seeds.should == yaml_hash["db"]["seeds"]
|
236
|
+
end
|
237
|
+
|
231
238
|
end
|
232
239
|
|
233
240
|
it "use custom config from file" do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
describe 'Standalone migrations' do
|
2
4
|
|
3
5
|
def write(file, content)
|
@@ -81,7 +83,7 @@ end
|
|
81
83
|
write_rakefile
|
82
84
|
write 'db/config.yml', <<-TXT
|
83
85
|
development:
|
84
|
-
adapter:
|
86
|
+
adapter: sqlite3
|
85
87
|
database: db/development.sql
|
86
88
|
test:
|
87
89
|
adapter: sqlite3
|
@@ -107,6 +109,25 @@ test:
|
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
112
|
+
describe 'callbacks' do
|
113
|
+
it 'runs the callbacks' do
|
114
|
+
StandaloneMigrations::Tasks.should_receive(:configure)
|
115
|
+
|
116
|
+
connection_established = false
|
117
|
+
ActiveRecord::Base.should_receive(:establish_connection) do
|
118
|
+
connection_established = true
|
119
|
+
end
|
120
|
+
StandaloneMigrations.should_receive(:run_on_load_callbacks) do
|
121
|
+
connection_established.should be_true
|
122
|
+
end
|
123
|
+
|
124
|
+
Dir.chdir(File.join(File.dirname(__FILE__), "tmp")) do
|
125
|
+
load "Rakefile"
|
126
|
+
Rake::Task['standalone:connection'].invoke
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
110
131
|
describe 'db:new_migration' do
|
111
132
|
it "fails if i do not add a name" do
|
112
133
|
lambda{ run("rake db:new_migration") }.should raise_error(/name=/)
|
@@ -296,15 +317,15 @@ test:
|
|
296
317
|
end
|
297
318
|
|
298
319
|
describe 'db:migrate when environment is specified' do
|
299
|
-
it "runs when using the DB environment variable" do
|
320
|
+
it "runs when using the DB environment variable", :travis_error => true do
|
300
321
|
make_migration('yyy')
|
301
|
-
run('rake db:migrate
|
302
|
-
run('rake db:version
|
322
|
+
run('rake db:migrate RAILS_ENV=test')
|
323
|
+
run('rake db:version RAILS_ENV=test').should_not =~ /version: 0/
|
303
324
|
run('rake db:version').should =~ /version: 0/
|
304
325
|
end
|
305
326
|
|
306
|
-
it "should error on an invalid database" do
|
307
|
-
lambda{ run("rake db:create
|
327
|
+
it "should error on an invalid database", :travis_error => true do
|
328
|
+
lambda{ run("rake db:create RAILS_ENV=nonexistent")}.should raise_error(/rake aborted/)
|
308
329
|
end
|
309
330
|
end
|
310
331
|
end
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: standalone_migrations 2.1.
|
5
|
+
# stub: standalone_migrations 2.1.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "standalone_migrations"
|
9
|
-
s.version = "2.1.
|
9
|
+
s.version = "2.1.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Todd Huss", "Michael Grosser"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-08-26"
|
15
15
|
s.email = "thuss@gabrito.com"
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"example/db/config.yml",
|
31
31
|
"example/db/migrate/20120930053225_create_table_awesome_migration.rb",
|
32
32
|
"lib/standalone_migrations.rb",
|
33
|
+
"lib/standalone_migrations/callbacks.rb",
|
33
34
|
"lib/standalone_migrations/configurator.rb",
|
34
35
|
"lib/standalone_migrations/generator.rb",
|
35
36
|
"lib/standalone_migrations/minimal_railtie_config.rb",
|
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
|
|
39
40
|
"lib/standalone_migrations/tasks/environment.rake",
|
40
41
|
"lib/tasks/standalone_migrations.rb",
|
41
42
|
"spec/spec_helper.rb",
|
43
|
+
"spec/standalone_migrations/callbacks_spec.rb",
|
42
44
|
"spec/standalone_migrations/configurator_spec.rb",
|
43
45
|
"spec/standalone_migrations_spec.rb",
|
44
46
|
"standalone_migrations.gemspec",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standalone_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Huss
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- example/db/config.yml
|
74
74
|
- example/db/migrate/20120930053225_create_table_awesome_migration.rb
|
75
75
|
- lib/standalone_migrations.rb
|
76
|
+
- lib/standalone_migrations/callbacks.rb
|
76
77
|
- lib/standalone_migrations/configurator.rb
|
77
78
|
- lib/standalone_migrations/generator.rb
|
78
79
|
- lib/standalone_migrations/minimal_railtie_config.rb
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- lib/standalone_migrations/tasks/environment.rake
|
83
84
|
- lib/tasks/standalone_migrations.rb
|
84
85
|
- spec/spec_helper.rb
|
86
|
+
- spec/standalone_migrations/callbacks_spec.rb
|
85
87
|
- spec/standalone_migrations/configurator_spec.rb
|
86
88
|
- spec/standalone_migrations_spec.rb
|
87
89
|
- standalone_migrations.gemspec
|