nonschema_migrations 3.0.1 → 5.1.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: 63001140252d2427c6d7ca56069ddf63633941c94350f4cfd04f8b88290cc568
4
- data.tar.gz: af9cf93b6f6fac5bf7ac755935c5f6a7c6ddd531bbe4c35805d96d67b70079df
3
+ metadata.gz: 548cbf414a8294a059f8ea134b04c55b61b22327eb2487c6f27c78253448c6a1
4
+ data.tar.gz: 41a26eea2b8565e486de2178f593bbfc7a7a2d875b62ab7fc443502b6d0c1cae
5
5
  SHA512:
6
- metadata.gz: 655d20058daecd6ba7ca2feb9ab4940fef0e1d39526f4edabc97f0c534d8857ce4105fb765bf94da0136b6b4b59777dd8199075e19f6a360184a5057ec818ca2
7
- data.tar.gz: 054f4bb67a781214fe60f4df1674fc7f757d98ef8d678b9429b38856e98a98ed5684ab81cf137bb1983f1fe5f0e2dccffb8ef5fa73573531662add89fc59e87f
6
+ metadata.gz: 7c915a45cad9df1ddea2df6b70b32f50468e905dfb076a3be91e752e73bdb4bacc31403ac951927ed85e286feaf8dfc3914e16f2803d2309ca439cc62f0823e6
7
+ data.tar.gz: f7d41831c51a8a06579f3274feaef7f3ce32a68b67e62815796aec23589cb9ccf97536516541274c1a6c15557db18b611ce501f087a322479d22862ec68d7093
@@ -1,4 +1,4 @@
1
- class CreateDataMigrations < ActiveRecord::Migration[5.1]
1
+ class CreateDataMigrations < ActiveRecord::Migration[5.2]
2
2
  def self.up
3
3
  create_table :data_migrations do |t|
4
4
  t.string :version
@@ -1,4 +1,3 @@
1
-
2
1
  MIGRATIONS_PATH = 'db/data_migrate'
3
2
 
4
3
  require 'generators/data_migrations/install_generator.rb'
@@ -1,21 +1,32 @@
1
-
2
-
3
-
4
1
  class NonschemaMigrator < ActiveRecord::Migrator
5
2
  # This class related to data migration.
6
3
  # Used in rake tasks (rake data:[migrate|rollback|up|down])
7
4
 
5
+ def initialize(direction, migrations, no_op, target_version = nil)
6
+ @direction = direction
7
+ @target_version = target_version
8
+ @migrated_versions = nil
9
+ @migrations = migrations
10
+
11
+ validate(@migrations)
12
+
13
+ ActiveRecord::InternalMetadata.create_table
14
+ end
15
+
8
16
  if defined?(ActiveRecord::MigrationContext)
9
- class SchemaMigration < ActiveRecord::SchemaMigration
17
+ class NonSchemaMigration < ActiveRecord::SchemaMigration
10
18
  def self.table_name
11
19
  NonschemaMigrator.schema_migrations_table_name
12
20
  end
13
21
  end
14
22
 
15
23
  class MigrationContext < ActiveRecord::MigrationContext
16
- def initialize(migrations_paths)
17
- super(migrations_paths)
18
- @schema_migration = NonschemaMigrator::SchemaMigration
24
+ def initialize(migrations_paths, data_migration)
25
+
26
+ # super(migrations_paths, data_migration)
27
+ @migrations_paths = migrations_paths
28
+
29
+ @schema_migration = NonschemaMigrator::NonSchemaMigration
19
30
  end
20
31
 
21
32
  def new_migrator(*args)
@@ -26,7 +37,7 @@ class NonschemaMigrator < ActiveRecord::Migrator
26
37
 
27
38
  # these methods are copied from ActiveRecord::Migrator
28
39
  # replaced:
29
- # 1.) ActiveRecord::SchemaMigration with @schema_migration
40
+ # 1.) ActiveRecord::NonSchemaMigration with @schema_migration
30
41
  # 2.) ActiveRecord::Migrator.new with new_migrator
31
42
 
32
43
  def get_all_versions
@@ -55,14 +66,12 @@ class NonschemaMigrator < ActiveRecord::Migrator
55
66
  (db_list + file_list).sort_by { |_, version, _| version }
56
67
  end
57
68
 
58
-
59
69
  def rollback(steps)
60
70
  move(:down, steps)
61
71
  end
62
72
 
63
-
64
73
  def move(direction, steps)
65
- migrator = new_migrator(direction, migrations)
74
+ migrator = new_migrator(direction, migrations, schema_migration)
66
75
 
67
76
  if current_version != 0 && !migrator.current_migration
68
77
  raise UnknownMigrationVersionError.new(current_version)
@@ -82,20 +91,20 @@ class NonschemaMigrator < ActiveRecord::Migrator
82
91
 
83
92
  def up(target_version = nil)
84
93
  selected_migrations = if block_given?
85
- migrations.select { |m| yield m }
86
- else
87
- migrations
88
- end
94
+ migrations.select { |m| yield m }
95
+ else
96
+ migrations
97
+ end
89
98
 
90
99
  new_migrator(:up, selected_migrations, target_version).migrate
91
100
  end
92
101
 
93
102
  def down(target_version = nil)
94
103
  selected_migrations = if block_given?
95
- migrations.select { |m| yield m }
96
- else
97
- migrations
98
- end
104
+ migrations.select { |m| yield m }
105
+ else
106
+ migrations
107
+ end
99
108
 
100
109
  new_migrator(:down, selected_migrations, target_version).migrate
101
110
  end
@@ -103,7 +112,7 @@ class NonschemaMigrator < ActiveRecord::Migrator
103
112
 
104
113
  class << self
105
114
  def context(path)
106
- NonschemaMigrator::MigrationContext.new(path)
115
+ NonschemaMigrator::MigrationContext.new(path, ActiveRecord::DataMigration)
107
116
  end
108
117
 
109
118
  def new_migrator(path, *args)
@@ -116,6 +125,10 @@ class NonschemaMigrator < ActiveRecord::Migrator
116
125
  context(path).migrate()
117
126
  end
118
127
 
128
+ def rollback(path, steps = 1)
129
+ context(path).rollback(steps)
130
+ end
131
+
119
132
  def run(direction, path, target_version)
120
133
  new_migrator(path, direction, context(path).migrations, target_version).run
121
134
  end
@@ -145,7 +158,7 @@ class NonschemaMigrator < ActiveRecord::Migrator
145
158
  def migrations_path
146
159
  MIGRATIONS_PATH
147
160
  end
148
-
161
+
149
162
  def schema_migrations_table_name
150
163
  'data_migrations'
151
164
  end
@@ -162,4 +175,5 @@ class NonschemaMigrator < ActiveRecord::Migrator
162
175
  end
163
176
  end
164
177
  end
165
- end
178
+ end
179
+
@@ -12,10 +12,15 @@ namespace :data do
12
12
 
13
13
  desc "rollback data migration (#{MIGRATIONS_PATH})"
14
14
  task :rollback => :data_migration_dependencies do
15
- step = ENV['STEP'] ? ENV['STEP'].to_i : 1
16
- NonschemaMigrator.rollback(MIGRATIONS_PATH,step)
15
+ NonschemaMigrator.rollback(MIGRATIONS_PATH)
17
16
  end
18
17
 
18
+ desc "honeybear (#{MIGRATIONS_PATH})"
19
+ task :honeybear => :data_migration_dependencies do
20
+ puts "hello honeybear"
21
+ end
22
+
23
+
19
24
  namespace :migrate do
20
25
  desc %Q{runs the "up" for a given _data_ migration VERSION}
21
26
  task :up => :data_migration_dependencies do
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonschema_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-01 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.1'
19
+ version: '6.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6.0'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '5.1'
32
+ version: '7'
27
33
  description: Separate schema-only migrations from nonschema (data) migrations in your
28
34
  Rails app
29
35
  email: jason.fb@datatravels.com
@@ -39,11 +45,12 @@ files:
39
45
  - lib/nonschema_migrations/railtie.rb
40
46
  - lib/nonschema_migrator.rb
41
47
  - lib/tasks/data.rb
42
- homepage: https://github.com/jasonfb/nonschema_migrations
48
+ homepage: https://blog.jasonfleetwoodboldt.com/nonschema-migrations/
43
49
  licenses:
44
50
  - MIT
45
- metadata: {}
46
- post_install_message:
51
+ metadata:
52
+ source_code_uri: https://github.com/jasonfb/nonschema_migrations
53
+ post_install_message:
47
54
  rdoc_options: []
48
55
  require_paths:
49
56
  - lib
@@ -58,9 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
65
  - !ruby/object:Gem::Version
59
66
  version: '0'
60
67
  requirements: []
61
- rubyforge_project:
62
- rubygems_version: 2.7.9
63
- signing_key:
68
+ rubygems_version: 3.0.8
69
+ signing_key:
64
70
  specification_version: 4
65
71
  summary: Nonschema(data-only) migrations for your Rails app
66
72
  test_files: []