standalone_migrations 7.1.0 → 7.1.2
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/.github/workflows/CI.yml +42 -0
- data/.rspec +1 -1
- data/Gemfile +4 -3
- data/README.markdown +1 -0
- data/Rakefile +6 -20
- data/VERSION +1 -1
- data/example/Gemfile +6 -0
- data/example/README.markdown +23 -0
- data/example/Rakefile +1 -8
- data/example/app/models/movie.rb +4 -0
- data/example/article.pdf +0 -0
- data/example/boot.rb +9 -0
- data/example/db/.gitignore +1 -0
- data/example/db/migrate/20210202023614_create_movies.rb +11 -0
- data/example/db/schema.rb +22 -0
- data/lib/standalone_migrations/configurator.rb +3 -5
- data/spec/standalone_migrations/configurator_spec.rb +35 -47
- data/spec/standalone_migrations_spec.rb +33 -39
- data/standalone_migrations.gemspec +18 -10
- metadata +27 -31
- data/.travis.yml +0 -29
- data/example/.gitignore +0 -5
- data/example/db/migrate/20120930053225_create_table_awesome_migration.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5764e519800ba6fc51161d55f3d8e12634737d88f9de3e2620a2b0fc265edf9
|
4
|
+
data.tar.gz: 00575db5b1e043e6442b8ad01333eebe4b2c4f35ae7e76be3b30ba45e5ae62dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f9fd28fb80d93c9d217b66d655ea76dba963da11e2546fea7a41e84cd1d9bde1305d4c9c19836662ea50625182dcbb8156b925d1c8987c260fbfb9660d2250
|
7
|
+
data.tar.gz: 0dd36ec1ecf386948fb89ee65a781748c405d11f66d741b30028e922ac9444585e6180a1c441b147bd0eaed54080881baa3bf251e79e9e315156b50a25ca7e5c
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- '2.6'
|
17
|
+
- '2.7'
|
18
|
+
- '3.0'
|
19
|
+
- '3.1'
|
20
|
+
activerecord:
|
21
|
+
- '5.2'
|
22
|
+
- '6.0'
|
23
|
+
- '6.1'
|
24
|
+
- '7.0'
|
25
|
+
exclude:
|
26
|
+
- activerecord: '5.2'
|
27
|
+
ruby: '3.1'
|
28
|
+
- activerecord: '5.2'
|
29
|
+
ruby: '3.0'
|
30
|
+
- activerecord: '7.0'
|
31
|
+
ruby: '2.6'
|
32
|
+
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.activerecord }}
|
33
|
+
env:
|
34
|
+
AR: ~> ${{ matrix.activerecord }}
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v2
|
37
|
+
- uses: ruby/setup-ruby@v1
|
38
|
+
with:
|
39
|
+
ruby-version: ${{ matrix.ruby }}
|
40
|
+
bundler-cache: true
|
41
|
+
- run: |
|
42
|
+
bundle exec rake
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--color
|
1
|
+
--force-color
|
2
2
|
--profile
|
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rake', '>= 10.0'
|
4
|
-
gem 'activerecord', ENV['AR'] ? ENV['AR'].split(",") : [">=
|
5
|
-
gem 'railties', ENV['AR'] ? ENV['AR'].split(",") : [">=
|
4
|
+
gem 'activerecord', ENV['AR'] ? ENV['AR'].split(",") : [">= 6.0.0", "< 7.1.0"]
|
5
|
+
gem 'railties', ENV['AR'] ? ENV['AR'].split(",") : [">= 6.0.0", "< 7.1.0"]
|
6
|
+
gem 'nokogiri', "~> 1.14"
|
6
7
|
|
7
8
|
group :dev do
|
8
|
-
gem 'sqlite3',
|
9
|
+
gem 'sqlite3', '~> 1.5'
|
9
10
|
gem 'rspec', '>= 2.99.0'
|
10
11
|
gem 'jeweler'
|
11
12
|
end
|
data/README.markdown
CHANGED
data/Rakefile
CHANGED
@@ -1,32 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
-
task :default do
|
5
|
-
sh "rspec spec"
|
6
|
-
end
|
7
|
-
|
8
4
|
task :all do
|
9
5
|
sh "AR='~>3.0.0' bundle update activerecord && bundle exec rake"
|
10
6
|
sh "AR='~>3.1.0.rc4' bundle update activerecord && bundle exec rake"
|
11
7
|
end
|
12
8
|
|
13
|
-
|
14
|
-
namespace :specs do
|
9
|
+
begin
|
15
10
|
require 'rspec/core/rake_task'
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
t.pattern = "spec/standalone_migrations/**/*_spec.rb"
|
20
|
-
end
|
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
|
-
|
28
|
-
desc "run all specs including those which uses database"
|
29
|
-
task :all => [:default, :nodb]
|
11
|
+
RSpec::Core::RakeTask.new(:spec)
|
12
|
+
rescue LoadError
|
13
|
+
# no rspec available
|
30
14
|
end
|
31
15
|
|
32
16
|
# rake install -> install gem locally (for tests)
|
@@ -50,3 +34,5 @@ else
|
|
50
34
|
|
51
35
|
Jeweler::GemcutterTasks.new
|
52
36
|
end
|
37
|
+
|
38
|
+
task default: "spec"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.1.
|
1
|
+
7.1.2
|
data/example/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
This is an example minimal app based off of
|
2
|
+
[this blog post](https://www.techcareerbooster.com/blog/use-activerecord-in-your-ruby-project),
|
3
|
+
archived [here](article.pdf) with permission of the author.
|
4
|
+
|
5
|
+
It demonstrates:
|
6
|
+
|
7
|
+
* database configuration
|
8
|
+
* a migration
|
9
|
+
* a model
|
10
|
+
* loading all relevant code into a runtime and using it
|
11
|
+
|
12
|
+
|
13
|
+
```
|
14
|
+
bundle
|
15
|
+
bundle exec rake db:create
|
16
|
+
bundle exec rake db:migrate
|
17
|
+
bundle exec irb -r ./boot.rb
|
18
|
+
```
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Movie.create! title: "Attack of the Cats", director: "Furball McCat"
|
22
|
+
Movie.count
|
23
|
+
```
|
data/example/Rakefile
CHANGED
@@ -1,9 +1,2 @@
|
|
1
|
-
|
2
|
-
# gem is installed
|
3
|
-
lib = File.expand_path("../../lib", __FILE__)
|
4
|
-
$:.unshift lib unless $:.include?(lib)
|
5
|
-
|
6
|
-
require "standalone_migrations"
|
1
|
+
require 'standalone_migrations'
|
7
2
|
StandaloneMigrations::Tasks.load_tasks
|
8
|
-
|
9
|
-
# and that's it!
|
data/example/article.pdf
ADDED
Binary file
|
data/example/boot.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require_relative './app/models/movie'
|
3
|
+
|
4
|
+
def db_configuration
|
5
|
+
db_configuration_file = File.join(File.expand_path('..', __FILE__), '.', 'db', 'config.yml')
|
6
|
+
YAML.load(File.read(db_configuration_file))
|
7
|
+
end
|
8
|
+
|
9
|
+
ActiveRecord::Base.establish_connection(db_configuration["development"])
|
@@ -0,0 +1 @@
|
|
1
|
+
*.sqlite3
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `rails
|
6
|
+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2021_02_02_023614) do
|
14
|
+
|
15
|
+
create_table "movies", force: :cascade do |t|
|
16
|
+
t.string "title", null: false
|
17
|
+
t.string "director", null: false
|
18
|
+
t.datetime "created_at", precision: 6, null: false
|
19
|
+
t.datetime "updated_at", precision: 6, null: false
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -32,17 +32,15 @@ module StandaloneMigrations
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def initialize(options = {})
|
35
|
-
default_schema = ENV['SCHEMA'] || ActiveRecord::Tasks::DatabaseTasks.schema_file(ActiveRecord::Base.schema_format)
|
36
35
|
defaults = {
|
37
36
|
:config => "db/config.yml",
|
38
37
|
:migrate_dir => "db/migrate",
|
39
38
|
:root => Pathname.pwd,
|
40
39
|
:seeds => "db/seeds.rb",
|
41
|
-
:schema => default_schema
|
42
40
|
}
|
43
41
|
@options = load_from_file(defaults.dup) || defaults.merge(options)
|
44
42
|
|
45
|
-
ENV['SCHEMA']
|
43
|
+
ENV['SCHEMA'] ||= schema if schema
|
46
44
|
Rails.application.config.root = root
|
47
45
|
Rails.application.config.paths["config/database"] = config
|
48
46
|
Rails.application.config.paths["db/migrate"] = migrate_dir
|
@@ -88,14 +86,14 @@ module StandaloneMigrations
|
|
88
86
|
end
|
89
87
|
|
90
88
|
def load_from_file(defaults)
|
91
|
-
return nil unless File.
|
89
|
+
return nil unless File.exist? configuration_file
|
92
90
|
config = YAML.load( ERB.new(IO.read(configuration_file)).result )
|
93
91
|
{
|
94
92
|
:config => config["config"] ? config["config"]["database"] : defaults[:config],
|
95
93
|
:migrate_dir => (config["db"] || {})["migrate"] || defaults[:migrate_dir],
|
96
94
|
:root => config["root"] || defaults[:root],
|
97
95
|
:seeds => (config["db"] || {})["seeds"] || defaults[:seeds],
|
98
|
-
:schema => (config["db"] || {})["schema"]
|
96
|
+
:schema => (config["db"] || {})["schema"]
|
99
97
|
}
|
100
98
|
end
|
101
99
|
|
@@ -4,30 +4,36 @@ require 'yaml'
|
|
4
4
|
module StandaloneMigrations
|
5
5
|
describe Configurator, "which allows define custom dirs and files to work with your migrations" do
|
6
6
|
|
7
|
-
|
7
|
+
around(:each) do |example|
|
8
|
+
Dir.mktmpdir do |dir|
|
9
|
+
Dir.chdir(dir) do
|
10
|
+
example.run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
8
14
|
|
15
|
+
describe "environment yaml configuration loading" do
|
9
16
|
|
10
17
|
let(:env_hash_other_db) do
|
11
18
|
{
|
12
|
-
"development" => {
|
13
|
-
"test" => {
|
14
|
-
"production" => {"adapter" => "mysql2", "database" => "database_name"
|
19
|
+
"development" => {"adapter" => "mysql2", "database" => "database_name"},
|
20
|
+
"test" => {"adapter" => "mysql2", "database" => "database_name"},
|
21
|
+
"production" => {"adapter" => "mysql2", "database" => "database_name"}
|
15
22
|
}
|
16
23
|
end
|
17
24
|
|
18
|
-
|
25
|
+
around(:each) do |example|
|
19
26
|
@env_hash = {
|
20
|
-
"development" => {
|
21
|
-
"test" => {
|
22
|
-
"production" => {"adapter" => "sqlite3", "database" => ":memory:"
|
27
|
+
"development" => {"adapter" => "sqlite3", "database" => "db/development.sql"},
|
28
|
+
"test" => {"adapter" => "sqlite3", "database" => "db/test.sql"},
|
29
|
+
"production" => {"adapter" => "sqlite3", "database" => ":memory:"}
|
23
30
|
}
|
24
|
-
|
25
|
-
Dir.chdir( File.expand_path("../../", __FILE__) )
|
26
|
-
FileUtils.mkdir_p "tmp/db"
|
27
|
-
Dir.chdir "tmp"
|
31
|
+
FileUtils.mkdir_p "db"
|
28
32
|
File.open("db/config.yml", "w") do |f|
|
29
33
|
f.write @env_hash.to_yaml
|
30
34
|
end
|
35
|
+
|
36
|
+
example.run
|
31
37
|
end
|
32
38
|
|
33
39
|
it "load the specific environment config" do
|
@@ -49,7 +55,7 @@ module StandaloneMigrations
|
|
49
55
|
let(:configurator) { Configurator.new }
|
50
56
|
|
51
57
|
before(:all) do
|
52
|
-
@new_config = {
|
58
|
+
@new_config = {'sbrobous' => 'test'}
|
53
59
|
Configurator.environments_config do |env|
|
54
60
|
env.on "production" do
|
55
61
|
@new_config
|
@@ -80,14 +86,9 @@ module StandaloneMigrations
|
|
80
86
|
|
81
87
|
end
|
82
88
|
|
83
|
-
after(:all) do
|
84
|
-
Dir.chdir @original_dir
|
85
|
-
end
|
86
|
-
|
87
89
|
end
|
88
90
|
|
89
91
|
context "default values when .standalone_configurations is missing" do
|
90
|
-
|
91
92
|
let(:configurator) do
|
92
93
|
Configurator.new
|
93
94
|
end
|
@@ -103,20 +104,15 @@ module StandaloneMigrations
|
|
103
104
|
it "use db/seeds.rb" do
|
104
105
|
expect(configurator.seeds).to eq("db/seeds.rb")
|
105
106
|
end
|
106
|
-
|
107
|
-
it "use db/schema.rb" do
|
108
|
-
expect(configurator.schema).to end_with("/db/schema.rb")
|
109
|
-
end
|
110
|
-
|
111
107
|
end
|
112
108
|
|
113
109
|
context "passing configurations as a parameter" do
|
114
110
|
let(:args) do
|
115
111
|
{
|
116
|
-
:config
|
117
|
-
:migrate_dir
|
118
|
-
:seeds
|
119
|
-
:schema
|
112
|
+
:config => "custom/config/database.yml",
|
113
|
+
:migrate_dir => "custom/db/migrate",
|
114
|
+
:seeds => "custom/db/seeds.rb",
|
115
|
+
:schema => "custom/db/schema.rb"
|
120
116
|
}
|
121
117
|
end
|
122
118
|
|
@@ -144,17 +140,17 @@ module StandaloneMigrations
|
|
144
140
|
|
145
141
|
context "using a .standalone_migrations file with configurations" do
|
146
142
|
|
147
|
-
before(:
|
148
|
-
|
149
|
-
|
143
|
+
before(:each) do
|
144
|
+
file = ".standalone_migrations"
|
145
|
+
File.open(file, "w") { |file| file.write(yaml_hash.to_yaml) }
|
150
146
|
end
|
151
147
|
|
152
148
|
let(:yaml_hash) do
|
153
149
|
{
|
154
150
|
"db" => {
|
155
|
-
"seeds"
|
156
|
-
"migrate"
|
157
|
-
"schema"
|
151
|
+
"seeds" => "file/db/seeds.rb",
|
152
|
+
"migrate" => "file/db/migrate",
|
153
|
+
"schema" => "file/db/schema.rb"
|
158
154
|
},
|
159
155
|
"config" => {
|
160
156
|
"database" => "file/config/database.yml"
|
@@ -165,9 +161,9 @@ module StandaloneMigrations
|
|
165
161
|
let(:yaml_hash_other_db) do
|
166
162
|
{
|
167
163
|
"db" => {
|
168
|
-
"seeds"
|
169
|
-
"migrate"
|
170
|
-
"schema"
|
164
|
+
"seeds" => "db2/seeds.rb",
|
165
|
+
"migrate" => "db2/migrate",
|
166
|
+
"schema" => "db2/schema.rb"
|
171
167
|
},
|
172
168
|
"config" => {
|
173
169
|
"database" => "config/config_other.yml"
|
@@ -176,20 +172,18 @@ module StandaloneMigrations
|
|
176
172
|
end
|
177
173
|
|
178
174
|
let(:configurator) do
|
179
|
-
file = ".standalone_migrations"
|
180
|
-
File.open(file, "w") { |file| file.write(yaml_hash.to_yaml) }
|
181
175
|
Configurator.new
|
182
176
|
end
|
183
177
|
|
184
178
|
context "with database environment variable passed" do
|
185
179
|
|
186
|
-
before(:
|
180
|
+
before(:each) do
|
187
181
|
ENV['DATABASE'] = "other_db"
|
182
|
+
file_other_db = ".other_db.standalone_migrations"
|
183
|
+
File.open(file_other_db, "w") { |file| file.write(yaml_hash_other_db.to_yaml) }
|
188
184
|
end
|
189
185
|
|
190
186
|
let(:other_configurator) do
|
191
|
-
file_other_db = ".other_db.standalone_migrations"
|
192
|
-
File.open(file_other_db, "w") { |file| file.write(yaml_hash_other_db.to_yaml) }
|
193
187
|
Configurator.new
|
194
188
|
end
|
195
189
|
|
@@ -202,7 +196,6 @@ module StandaloneMigrations
|
|
202
196
|
end
|
203
197
|
|
204
198
|
after(:all) do
|
205
|
-
File.delete ".other_db.standalone_migrations"
|
206
199
|
ENV['DATABASE'] = nil
|
207
200
|
end
|
208
201
|
|
@@ -251,11 +244,6 @@ module StandaloneMigrations
|
|
251
244
|
expect(configurator.schema).to eq(yaml_hash["db"]["schema"])
|
252
245
|
end
|
253
246
|
|
254
|
-
after(:all) do
|
255
|
-
File.delete ".standalone_migrations"
|
256
|
-
Dir.chdir @original_dir
|
257
|
-
end
|
258
|
-
|
259
247
|
end
|
260
248
|
end
|
261
249
|
end
|
@@ -3,36 +3,31 @@ describe 'Standalone migrations' do
|
|
3
3
|
|
4
4
|
def write(file, content)
|
5
5
|
raise "cannot write nil" unless file
|
6
|
-
file = tmp_file(file)
|
7
6
|
folder = File.dirname(file)
|
8
|
-
|
7
|
+
FileUtils.mkdir_p(folder) if folder != ''
|
9
8
|
File.open(file, 'w') { |f| f.write content }
|
10
9
|
end
|
11
10
|
|
12
11
|
def read(file)
|
13
|
-
File.read(
|
12
|
+
File.read(file)
|
14
13
|
end
|
15
14
|
|
16
15
|
def migration(name)
|
17
|
-
m = `cd
|
16
|
+
m = `cd db/migrate && ls`.split("\n").detect { |m| m =~ /#{name}/ }
|
18
17
|
m ? "db/migrate/#{m}" : m
|
19
18
|
end
|
20
19
|
|
21
|
-
def tmp_file(file)
|
22
|
-
"spec/tmp/#{file}"
|
23
|
-
end
|
24
|
-
|
25
20
|
def schema
|
26
|
-
ENV['SCHEMA']
|
21
|
+
ENV['SCHEMA'] || ActiveRecord::Tasks::DatabaseTasks.schema_file(ActiveRecord::Base.schema_format)
|
27
22
|
end
|
28
23
|
|
29
24
|
def run(cmd)
|
30
|
-
result =
|
25
|
+
result = `#{cmd} 2>&1`
|
31
26
|
raise result unless $?.success?
|
32
27
|
result
|
33
28
|
end
|
34
29
|
|
35
|
-
def make_migration(name, options={})
|
30
|
+
def make_migration(name, options = {})
|
36
31
|
task_name = options[:task_name] || 'db:new_migration'
|
37
32
|
migration = run("rake #{task_name} name=#{name}").match(%r{db/migrate/\d+.*.rb})[0]
|
38
33
|
content = read(migration)
|
@@ -42,9 +37,9 @@ describe 'Standalone migrations' do
|
|
42
37
|
migration.match(/\d{14}/)[0]
|
43
38
|
end
|
44
39
|
|
45
|
-
def write_rakefile(config=nil)
|
40
|
+
def write_rakefile(config = nil)
|
46
41
|
write 'Rakefile', <<-TXT
|
47
|
-
$LOAD_PATH.unshift '#{File.expand_path('lib')}'
|
42
|
+
$LOAD_PATH.unshift '#{File.expand_path('../../lib')}'
|
48
43
|
begin
|
49
44
|
require "standalone_migrations"
|
50
45
|
StandaloneMigrations::Tasks.load_tasks
|
@@ -56,10 +51,10 @@ end
|
|
56
51
|
|
57
52
|
def write_multiple_migrations
|
58
53
|
migration_superclass = if Rails::VERSION::MAJOR >= 5
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
"ActiveRecord::Migration[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
55
|
+
else
|
56
|
+
"ActiveRecord::Migration"
|
57
|
+
end
|
63
58
|
|
64
59
|
write_rakefile %{t.migrations = "db/migrations", "db/migrations2"}
|
65
60
|
write "db/migrate/20100509095815_create_tests.rb", <<-TXT
|
@@ -86,10 +81,17 @@ end
|
|
86
81
|
TXT
|
87
82
|
end
|
88
83
|
|
84
|
+
around(:each) do |example|
|
85
|
+
FileUtils.mkdir_p('tmp')
|
86
|
+
Dir.mktmpdir("spec-", "tmp") do |dir|
|
87
|
+
Dir.chdir(dir) do
|
88
|
+
example.run
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
89
93
|
before do
|
90
94
|
StandaloneMigrations::Configurator.instance_variable_set(:@env_config, nil)
|
91
|
-
`rm -rf spec/tmp` if File.exist?('spec/tmp')
|
92
|
-
`mkdir spec/tmp`
|
93
95
|
write_rakefile
|
94
96
|
write(schema, '')
|
95
97
|
write 'db/config.yml', <<-TXT
|
@@ -105,10 +107,6 @@ production:
|
|
105
107
|
TXT
|
106
108
|
end
|
107
109
|
|
108
|
-
after(:all) do
|
109
|
-
`rm -rf spec/tmp` if File.exist?('spec/tmp')
|
110
|
-
end
|
111
|
-
|
112
110
|
it "warns of deprecated folder structure" do
|
113
111
|
warning = /DEPRECATED.* db\/migrate/
|
114
112
|
expect(run("rake db:create")).not_to match(warning)
|
@@ -135,16 +133,14 @@ production:
|
|
135
133
|
expect(connection_established).to be true
|
136
134
|
end
|
137
135
|
|
138
|
-
|
139
|
-
|
140
|
-
Rake::Task['standalone:connection'].invoke
|
141
|
-
end
|
136
|
+
load "Rakefile"
|
137
|
+
Rake::Task['standalone:connection'].invoke
|
142
138
|
end
|
143
139
|
end
|
144
140
|
|
145
141
|
describe 'db:new_migration' do
|
146
142
|
it "fails if i do not add a name" do
|
147
|
-
expect
|
143
|
+
expect { run("rake db:new_migration") }.to raise_error(/name=/)
|
148
144
|
end
|
149
145
|
|
150
146
|
it "generates a new migration with this name from ENV and timestamp" do
|
@@ -213,7 +209,7 @@ production:
|
|
213
209
|
make_migration('yyy')
|
214
210
|
# Rails has a bug where it's sending a bad failure exception
|
215
211
|
# https://github.com/rails/rails/issues/28905
|
216
|
-
expect
|
212
|
+
expect { run("rake db:migrate:down") }.to raise_error(/VERSION|version/)
|
217
213
|
end
|
218
214
|
end
|
219
215
|
|
@@ -232,7 +228,7 @@ production:
|
|
232
228
|
make_migration('yyy')
|
233
229
|
# Rails has a bug where it's sending a bad failure exception
|
234
230
|
# https://github.com/rails/rails/issues/28905
|
235
|
-
expect
|
231
|
+
expect { run("rake db:migrate:up") }.to raise_error(/VERSION|version/)
|
236
232
|
end
|
237
233
|
end
|
238
234
|
|
@@ -271,7 +267,7 @@ production:
|
|
271
267
|
describe 'db:schema:load' do
|
272
268
|
it "loads the schema" do
|
273
269
|
run('rake db:schema:dump')
|
274
|
-
write(schema, read(schema)+"\nputs 'LOADEDDD'")
|
270
|
+
write(schema, read(schema) + "\nputs 'LOADEDDD'")
|
275
271
|
result = run('rake db:schema:load')
|
276
272
|
expect(result).to match(/LOADEDDD/)
|
277
273
|
end
|
@@ -282,7 +278,7 @@ production:
|
|
282
278
|
run "rake db:drop"
|
283
279
|
run "rake db:create"
|
284
280
|
run "rake db:schema:load"
|
285
|
-
expect(run(
|
281
|
+
expect(run("rake db:migrate").strip).to eq('')
|
286
282
|
end
|
287
283
|
end
|
288
284
|
|
@@ -293,7 +289,7 @@ production:
|
|
293
289
|
|
294
290
|
it "fails when migrations are pending" do
|
295
291
|
make_migration('yyy')
|
296
|
-
expect
|
292
|
+
expect { run("rake db:abort_if_pending_migrations") }.to raise_error(/1 pending migration/)
|
297
293
|
end
|
298
294
|
end
|
299
295
|
|
@@ -304,9 +300,9 @@ production:
|
|
304
300
|
end
|
305
301
|
|
306
302
|
it "fails without schema" do
|
307
|
-
schema_path =
|
303
|
+
schema_path = schema
|
308
304
|
`rm -rf #{schema_path}` if File.exist?(schema_path)
|
309
|
-
expect
|
305
|
+
expect { run("rake db:test:load") }.to raise_error(/try again/)
|
310
306
|
end
|
311
307
|
end
|
312
308
|
|
@@ -335,14 +331,12 @@ production:
|
|
335
331
|
write(".standalone_migrations", yaml_hash.to_yaml)
|
336
332
|
end
|
337
333
|
|
338
|
-
|
339
334
|
it "loads" do
|
340
335
|
write("db/seeds2.rb", "puts 'LOADEDDD'")
|
341
336
|
expect(run("rake db:seed")).to match(/LOADEDDD/)
|
342
337
|
end
|
343
338
|
end
|
344
339
|
|
345
|
-
|
346
340
|
it "does nothing without seeds" do
|
347
341
|
expect(run("rake db:seed").length).to eq(0)
|
348
342
|
end
|
@@ -352,7 +346,7 @@ production:
|
|
352
346
|
it "should not error when a seeds file does not exist" do
|
353
347
|
make_migration('yyy')
|
354
348
|
run('rake db:migrate DB=test')
|
355
|
-
expect
|
349
|
+
expect { run("rake db:reset") }.not_to raise_error
|
356
350
|
end
|
357
351
|
end
|
358
352
|
|
@@ -365,7 +359,7 @@ production:
|
|
365
359
|
end
|
366
360
|
|
367
361
|
it "should error on an invalid database", :travis_error => true do
|
368
|
-
expect
|
362
|
+
expect { run("rake db:create RAILS_ENV=nonexistent") }.to raise_error(/rake aborted/)
|
369
363
|
end
|
370
364
|
end
|
371
365
|
end
|
@@ -2,33 +2,39 @@
|
|
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 7.1.
|
5
|
+
# stub: standalone_migrations 7.1.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "standalone_migrations".freeze
|
9
|
-
s.version = "7.1.
|
9
|
+
s.version = "7.1.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Todd Huss".freeze, "Michael Grosser".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2023-11-02"
|
15
15
|
s.email = "thuss@gabrito.com".freeze
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
18
|
"README.markdown"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
+
".github/workflows/CI.yml",
|
21
22
|
".rspec",
|
22
|
-
".travis.yml",
|
23
23
|
"Gemfile",
|
24
24
|
"LICENSE",
|
25
25
|
"README.markdown",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
|
-
"example
|
28
|
+
"example/Gemfile",
|
29
|
+
"example/README.markdown",
|
29
30
|
"example/Rakefile",
|
31
|
+
"example/app/models/movie.rb",
|
32
|
+
"example/article.pdf",
|
33
|
+
"example/boot.rb",
|
34
|
+
"example/db/.gitignore",
|
30
35
|
"example/db/config.yml",
|
31
|
-
"example/db/migrate/
|
36
|
+
"example/db/migrate/20210202023614_create_movies.rb",
|
37
|
+
"example/db/schema.rb",
|
32
38
|
"lib/standalone_migrations.rb",
|
33
39
|
"lib/standalone_migrations/callbacks.rb",
|
34
40
|
"lib/standalone_migrations/configurator.rb",
|
@@ -60,12 +66,14 @@ Gem::Specification.new do |s|
|
|
60
66
|
|
61
67
|
if s.respond_to? :add_runtime_dependency then
|
62
68
|
s.add_runtime_dependency(%q<rake>.freeze, [">= 10.0"])
|
63
|
-
s.add_runtime_dependency(%q<activerecord>.freeze, [">=
|
64
|
-
s.add_runtime_dependency(%q<railties>.freeze, [">=
|
69
|
+
s.add_runtime_dependency(%q<activerecord>.freeze, [">= 6.0.0", "< 7.1.0"])
|
70
|
+
s.add_runtime_dependency(%q<railties>.freeze, [">= 6.0.0", "< 7.1.0"])
|
71
|
+
s.add_runtime_dependency(%q<nokogiri>.freeze, ["~> 1.14"])
|
65
72
|
else
|
66
73
|
s.add_dependency(%q<rake>.freeze, [">= 10.0"])
|
67
|
-
s.add_dependency(%q<activerecord>.freeze, [">=
|
68
|
-
s.add_dependency(%q<railties>.freeze, [">=
|
74
|
+
s.add_dependency(%q<activerecord>.freeze, [">= 6.0.0", "< 7.1.0"])
|
75
|
+
s.add_dependency(%q<railties>.freeze, [">= 6.0.0", "< 7.1.0"])
|
76
|
+
s.add_dependency(%q<nokogiri>.freeze, ["~> 1.14"])
|
69
77
|
end
|
70
78
|
end
|
71
79
|
|
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: 7.1.
|
4
|
+
version: 7.1.2
|
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:
|
12
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -31,64 +31,54 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 6.0.0
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 7.1.0
|
38
|
-
- - "!="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 5.2.3
|
41
|
-
- - "!="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 5.2.3.rc1
|
44
38
|
type: :runtime
|
45
39
|
prerelease: false
|
46
40
|
version_requirements: !ruby/object:Gem::Requirement
|
47
41
|
requirements:
|
48
42
|
- - ">="
|
49
43
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
44
|
+
version: 6.0.0
|
51
45
|
- - "<"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 7.1.0
|
54
|
-
- - "!="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 5.2.3
|
57
|
-
- - "!="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 5.2.3.rc1
|
60
48
|
- !ruby/object:Gem::Dependency
|
61
49
|
name: railties
|
62
50
|
requirement: !ruby/object:Gem::Requirement
|
63
51
|
requirements:
|
64
52
|
- - ">="
|
65
53
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
54
|
+
version: 6.0.0
|
67
55
|
- - "<"
|
68
56
|
- !ruby/object:Gem::Version
|
69
57
|
version: 7.1.0
|
70
|
-
- - "!="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 5.2.3
|
73
|
-
- - "!="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 5.2.3.rc1
|
76
58
|
type: :runtime
|
77
59
|
prerelease: false
|
78
60
|
version_requirements: !ruby/object:Gem::Requirement
|
79
61
|
requirements:
|
80
62
|
- - ">="
|
81
63
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
64
|
+
version: 6.0.0
|
83
65
|
- - "<"
|
84
66
|
- !ruby/object:Gem::Version
|
85
67
|
version: 7.1.0
|
86
|
-
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: nokogiri
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
|
74
|
+
version: '1.14'
|
75
|
+
type: :runtime
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
90
80
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
81
|
+
version: '1.14'
|
92
82
|
description:
|
93
83
|
email: thuss@gabrito.com
|
94
84
|
executables: []
|
@@ -97,17 +87,23 @@ extra_rdoc_files:
|
|
97
87
|
- LICENSE
|
98
88
|
- README.markdown
|
99
89
|
files:
|
90
|
+
- ".github/workflows/CI.yml"
|
100
91
|
- ".rspec"
|
101
|
-
- ".travis.yml"
|
102
92
|
- Gemfile
|
103
93
|
- LICENSE
|
104
94
|
- README.markdown
|
105
95
|
- Rakefile
|
106
96
|
- VERSION
|
107
|
-
- example
|
97
|
+
- example/Gemfile
|
98
|
+
- example/README.markdown
|
108
99
|
- example/Rakefile
|
100
|
+
- example/app/models/movie.rb
|
101
|
+
- example/article.pdf
|
102
|
+
- example/boot.rb
|
103
|
+
- example/db/.gitignore
|
109
104
|
- example/db/config.yml
|
110
|
-
- example/db/migrate/
|
105
|
+
- example/db/migrate/20210202023614_create_movies.rb
|
106
|
+
- example/db/schema.rb
|
111
107
|
- lib/standalone_migrations.rb
|
112
108
|
- lib/standalone_migrations/callbacks.rb
|
113
109
|
- lib/standalone_migrations/configurator.rb
|
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.5.9
|
4
|
-
- 2.6.9
|
5
|
-
- 2.7.5
|
6
|
-
- 3.0.3
|
7
|
-
env:
|
8
|
-
- AR="~> 4.2.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
9
|
-
- AR="~> 5.0.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
10
|
-
- AR=">= 5.1.0.rc2,< 5.2" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
11
|
-
- AR=">= 5.2.0.rc2,< 5.3,!= 5.2.3,!=5.2.3.rc1" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
12
|
-
- AR="~> 6.0.0" SQL="~>1.4" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
13
|
-
- AR="~> 6.1.0" SQL="~>1.4" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
14
|
-
- AR="~> 7.0.0" SQL="~>1.4" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
15
|
-
jobs:
|
16
|
-
exclude:
|
17
|
-
- rvm: 2.6.9
|
18
|
-
env: AR="~> 4.2.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
19
|
-
- rvm: 2.7.5
|
20
|
-
env: AR="~> 4.2.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
21
|
-
- rvm: 3.0.3
|
22
|
-
env: AR="~> 4.2.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
23
|
-
- rvm: 2.7.5
|
24
|
-
env: AR="~> 5.0.0" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
25
|
-
- rvm: 2.7.5
|
26
|
-
env: AR=">= 5.1.0.rc2,< 5.2" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
27
|
-
- rvm: 2.7.5
|
28
|
-
env: AR=">= 5.2.0.rc2,< 5.3,!= 5.2.3,!=5.2.3.rc1" SQL="~>1.3.6" NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
29
|
-
script: bundle exec rake specs:travis
|
data/example/.gitignore
DELETED