rails_async_migrations 1.0.1 → 1.0.2

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: e24a2ed40f0fcdc9da52564f3cbac3164f5f51caf2b3ae4e0a0c230740c0fce3
4
- data.tar.gz: 6640134d706bf44a36d3d90758cb4830837c10bfb64f008b16f8b962829275e5
3
+ metadata.gz: 19fc441a029878e39ee6794467b9a442d0b3b2a7a6a2190612555478ee60689a
4
+ data.tar.gz: bc1947d8c051d3dbdecfda22c8efabb35cc75a2a012592b8f0a67e8f67ea64ac
5
5
  SHA512:
6
- metadata.gz: cf224109d383f1b7db33b8be88e6217e7fc4b771e8cd1509d2021f13619ebea6ae5aad0d4567167c7e1c1043b0d8d63b0d8261f7bee8d56a1b845f90e832447f
7
- data.tar.gz: 699120d94bf4cd2aa17521efb7b034578ba81d9e8dfa02552df66ea7d19f6d60dc2ffc546da7e60f672d8a7ce0ac57b9a02c73590ec6aa86403ca2a6dac2f865
6
+ metadata.gz: 6300eed27ef6c4007a24757aec057f4675b2b92d3fa4606e48c9b387307065d2ae0be82c84fe404364b5a96c662542498800e75dcdfbe2f5b1ba1eb6217da563
7
+ data.tar.gz: 13f506f3dc6bd466da06861e22d5e0fe781510f53e5a4c4d0c03e251d0db2081c4751c7ee0f9fe36150873b5ee2ea2565091f1f7120077528899fa98559cf6d3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_async_migrations (1.0.1)
4
+ rails_async_migrations (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -116,9 +116,13 @@ You can also manually launch the queue check and fire by using:
116
116
 
117
117
  ## Failure handling
118
118
 
119
- If your migration crashes, and blocks the rest of your asynchronous migrations but you want to execute them anyway, you can change the code of the migration file and push it again so it passes, or simply remove / update as `state = done` the matching `async_schema_migrations` row.
119
+ If your migration crashes, and blocks the rest of your queue but you want to execute them anyway, you can use multiple strategies to do so:
120
120
 
121
- The `version` value is always the same as the classic migrations ones.
121
+ - Change the code of the migration file and push it again so it passes
122
+ - Remove the matching row in the `async_schema_migrations` table
123
+ - Update the matching row with `state = done`
124
+
125
+ To find the matching migration, be aware the `version` value is always the same as the classic migrations ones, so it's pretty easy to find things around.
122
126
 
123
127
  ## Compatibility
124
128
 
@@ -1,8 +1,23 @@
1
1
  module RailsAsyncMigrations
2
2
  module Mutators
3
3
  class Base
4
+ # in some context we have to guess it from the file and current connection
5
+ # for instance when we use class methods such as `turn_async`
4
6
  def migration_class
5
- instance.class
7
+ if instance.class == ActiveRecord::Migration
8
+ fetch_from_file
9
+ else
10
+ instance.class
11
+ end
12
+ end
13
+
14
+ def fetch_from_file
15
+ require current_migration.filename
16
+ current_migration.name.constantize
17
+ end
18
+
19
+ def current_migration
20
+ @current_migration ||= Connection::ActiveRecord.new(:up).current_migration
6
21
  end
7
22
  end
8
23
  end
@@ -15,6 +15,7 @@ module RailsAsyncMigrations
15
15
  private
16
16
 
17
17
  def alter_migration
18
+ Tracer.new.verbose "#{migration_class} is now asynchronous"
18
19
  migration_class.include RailsAsyncMigrations::Migration
19
20
  end
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAsyncMigrations
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_async_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Schaffner