migration_data 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c8dbb5b25cfbd8b8e4c6b83e81fb23481644a48
4
- data.tar.gz: 92f5bc8d4c74dbdc460430553a76ff2cc7015507
3
+ metadata.gz: 2241ab7f5357ed22a693a1757bd85b8b070d2f9c
4
+ data.tar.gz: 7243033a82ab6b8d84be2b785c7a4746d800ac4a
5
5
  SHA512:
6
- metadata.gz: 3f4d04e8978a30b390c11371b3657ac806df432fc24831b830450975b49e09098f321051cf2d6b0913f931ec10599fe0f6089f5fa41f8ef502a379056ae868d7
7
- data.tar.gz: d4d7a9e33cc75794e073da3b2a3c9ea7980bd6496cd090b726f284d37ac891acd87f8bf8b8a92e5670ee2a9f85f37e91b728f220824150671bc3be534f821647
6
+ metadata.gz: 8ee640f1feda47ff6e8a1cc4ce594a45515d7d4450b65919309c071f4ebb86d384da5236534aa5f6d33c92ecc0cb2e3d534e73f8859ed2b709910fd2cde45088
7
+ data.tar.gz: 25316582cbbcd0bd4d7a20a94441a7e88205f51bea014c6b69b5e99ea6514172f76d10c8d0fd8de5a7533dff833ec4b3077e2e97a8b15323dc1c3a8e17a667b5
@@ -2,6 +2,6 @@ language: ruby
2
2
  before_install:
3
3
  - gem install bundler -v 1.11.2
4
4
  rvm:
5
- - 2.1.0
6
5
  - 2.2.2
7
6
  - 2.3.0
7
+ - 2.4.0
data/README.md CHANGED
@@ -10,7 +10,7 @@ some techniques which help to avoid these pitfalls. For example, define model
10
10
  classes in the migrations or write raw SQL. But they don't help in 100% of all cases.
11
11
  This gem promises to solve this problem in a simple way.
12
12
 
13
- Currently the gem supports Rails 4.
13
+ Currently the gem supports Rails 4 and Rails 5.
14
14
 
15
15
  If you still don't understand what this gem is for please check out [this blog post](http://railsguides.net/2014/01/30/change-data-in-migrations-like-a-boss/).
16
16
 
@@ -51,6 +51,8 @@ end
51
51
  That's it. Now when you run migrations with the `rake db:migrate` command the `data` method will be run on `up`.
52
52
  When you rollback migrations with the `rake db:rollback` command the `rollback` method will be run on `down`.
53
53
 
54
+ > Note: in some circumstances, the `reset_column_information` method should be called on a model which table is changed in the migration. Especially when you are certain that there should be present some column for a model but it's absent for some reason. Read more about this in the [official Rails docs](http://guides.rubyonrails.org/v4.1/migrations.html#using-models-in-your-migrations).
55
+
54
56
  ## Testing migrations
55
57
 
56
58
  To keep your migrations working don't forget to write tests for them. It's preferably to put the tests for migrations into `spec/db/migrations` folder, but actually it's up to you. Possible `RSpec` test (`spec/db/migrations/create_user.rb`) for the migration looks like this:
@@ -2,10 +2,10 @@ require 'rails'
2
2
 
3
3
  def require_migration(migration_name)
4
4
  path = MigrationData::ActiveRecord::Migration.migration_dir
5
- all_migrations = ActiveRecord::Migrator.migrations(path)
5
+ migrations = all_migrations(path)
6
6
 
7
7
  migration_name += '.rb' unless migration_name.end_with?('.rb')
8
- file = all_migrations.detect do |m|
8
+ file = migrations.detect do |m|
9
9
  m.filename.end_with?(migration_name)
10
10
  end
11
11
 
@@ -13,3 +13,11 @@ def require_migration(migration_name)
13
13
 
14
14
  require Rails.root.join(file.filename)
15
15
  end
16
+
17
+ def all_migrations(path)
18
+ if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 2
19
+ ActiveRecord::MigrationContext.new(path).migrations
20
+ else
21
+ ActiveRecord::Migrator.migrations(path)
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MigrationData
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class MyMigration < ActiveRecord::Migration
3
+ class MyMigration < ActiveRecord::Migration[4.2]
4
4
  attr_reader :migrated_data, :rolled_back_data
5
5
 
6
6
  def data
@@ -1,4 +1,4 @@
1
- class CreateTableMigration < ActiveRecord::Migration
1
+ class CreateTableMigration < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :users, force: true do |t|
4
4
  t.string :name
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migration_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Koleshko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: |-
@@ -64,8 +64,8 @@ executables: []
64
64
  extensions: []
65
65
  extra_rdoc_files: []
66
66
  files:
67
- - .gitignore
68
- - .travis.yml
67
+ - ".gitignore"
68
+ - ".travis.yml"
69
69
  - Gemfile
70
70
  - LICENSE.txt
71
71
  - README.md
@@ -100,17 +100,17 @@ require_paths:
100
100
  - lib
101
101
  required_ruby_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.0.14.1
113
+ rubygems_version: 2.5.1
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Provides possibility to write any code in migrations safely without regression.