nonschema_migrations 1.0.0 → 1.0.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
  SHA256:
3
- metadata.gz: da4a766ada05593da5379df6b6dc1fde7b18aae17138f07f458dab54784f019f
4
- data.tar.gz: c7d572cd3a1b3a37b2d6aa795efeb7939731ccbd9e2d14bee4d89ef1f447d74a
3
+ metadata.gz: 1fe1e88c13e4b47c9372f72634f12a9912ca8a97be8fd5d7cdc93be412da8578
4
+ data.tar.gz: 0f282f2a5c827b9a704f3bfee903ec0248fc1173fc7af5ca4e2630e9ce94ac91
5
5
  SHA512:
6
- metadata.gz: 17fb2d645b46f83ddb25c069e8e2beeae6eb80d7821a0abe4f65386897644a075e54c88088d09f91cbd31f157eba63b547225891f93a9097d3bd63a42cfa8249
7
- data.tar.gz: 83daa3c35a73bc96fbb26953e554a173f1079ea040b8737c6764b107efb7d2d8501dce9f337adf9cff4cc3a48bfcc7e7f787e37b9d0cc1da224234b8a76cdae1
6
+ metadata.gz: 43b4d62cf956e199c1a438bfda43238a9e94ea1d4ebc0fa6f7f22c5d41a49e47a645e6919ce9b8dda85e14642e2e0e1fefe3200ca50762cee3c73024001794fa
7
+ data.tar.gz: ed4583b344aa99ee1f91159d43bc91d8cb97e03fa773582e1593c0d59d67d50c43ecdbdebe0608b869d40b845ff2faa831f3932355e5f21cff3fc31035b8bd1f
@@ -6,6 +6,6 @@ require 'generators/data_migration_generator.rb'
6
6
  require 'active_record/data_migration.rb'
7
7
  require 'nonschema_migrator.rb'
8
8
 
9
- module NondestructiveMigrations
9
+ module NonschemaMigrations
10
10
  require "nonschema_migrations/railtie.rb" if defined?(Rails)
11
11
  end
@@ -1,25 +1,25 @@
1
1
 
2
2
 
3
3
 
4
- class NondestructiveMigrator < ActiveRecord::Migrator
4
+ class NonschemaMigrator < ActiveRecord::Migrator
5
5
  # This class related to data migration.
6
6
  # Used in rake tasks (rake data:[migrate|rollback|up|down])
7
7
 
8
8
  if defined?(ActiveRecord::MigrationContext)
9
9
  class SchemaMigration < ActiveRecord::SchemaMigration
10
10
  def self.table_name
11
- NondestructiveMigrator.schema_migrations_table_name
11
+ NonschemaMigrator.schema_migrations_table_name
12
12
  end
13
13
  end
14
14
 
15
15
  class MigrationContext < ActiveRecord::MigrationContext
16
16
  def initialize(migrations_paths)
17
17
  super(migrations_paths)
18
- @schema_migration = NondestructiveMigrator::SchemaMigration
18
+ @schema_migration = NonschemaMigrator::SchemaMigration
19
19
  end
20
20
 
21
21
  def new_migrator(*args)
22
- result = NondestructiveMigrator.new(*args)
22
+ result = NonschemaMigrator.new(*args)
23
23
  result.migration_context = self
24
24
  result
25
25
  end
@@ -55,6 +55,12 @@ class NondestructiveMigrator < ActiveRecord::Migrator
55
55
  (db_list + file_list).sort_by { |_, version, _| version }
56
56
  end
57
57
 
58
+
59
+ def rollback(steps)
60
+ move(:down, steps)
61
+ end
62
+
63
+
58
64
  def move(direction, steps)
59
65
  migrator = new_migrator(direction, migrations)
60
66
 
@@ -97,7 +103,7 @@ class NondestructiveMigrator < ActiveRecord::Migrator
97
103
 
98
104
  class << self
99
105
  def context(path)
100
- NondestructiveMigrator::MigrationContext.new(path)
106
+ NonschemaMigrator::MigrationContext.new(path)
101
107
  end
102
108
 
103
109
  def new_migrator(path, *args)
@@ -156,6 +162,4 @@ class NondestructiveMigrator < ActiveRecord::Migrator
156
162
  end
157
163
  end
158
164
  end
159
- end
160
-
161
-
165
+ end
data/lib/tasks/data.rb CHANGED
@@ -7,13 +7,13 @@ namespace :data do
7
7
 
8
8
  desc "run data migration (#{MIGRATIONS_PATH})"
9
9
  task :migrate => :data_migration_dependencies do
10
- NondestructiveMigrator.migrate(MIGRATIONS_PATH)
10
+ NonschemaMigrator.migrate(MIGRATIONS_PATH)
11
11
  end
12
12
 
13
13
  desc "rollback data migration (#{MIGRATIONS_PATH})"
14
14
  task :rollback => :data_migration_dependencies do
15
15
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
16
- NondestructiveMigrator.rollback(MIGRATIONS_PATH,step)
16
+ NonschemaMigrator.rollback(MIGRATIONS_PATH,step)
17
17
  end
18
18
 
19
19
  namespace :migrate do
@@ -21,14 +21,14 @@ namespace :data do
21
21
  task :up => :data_migration_dependencies do
22
22
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
23
23
  raise "VERSION is required" unless version
24
- NondestructiveMigrator.run(:up, MIGRATIONS_PATH, version)
24
+ NonschemaMigrator.run(:up, MIGRATIONS_PATH, version)
25
25
  end
26
26
 
27
27
  desc %Q{runs the "down" for a given _data_ migration VERSION}
28
28
  task :down => :data_migration_dependencies do
29
29
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
30
30
  raise "VERSION is required" unless version
31
- NondestructiveMigrator.run(:down, MIGRATIONS_PATH, version)
31
+ NonschemaMigrator.run(:down, MIGRATIONS_PATH, version)
32
32
  end
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonschema_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-12 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: 4.x
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: 4.x
27
27
  description: Separate schema-only migrations from nonschema (data) migrations in your
28
28
  Rails app
29
29
  email: jason.fb@datatravels.com