strong_migrations 0.7.0 → 0.7.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: 2ef314694846eec868e7e01b74fcfc9a29d361e01e3bc9102914a0bd3ba0facc
4
- data.tar.gz: b27a43c73b0c394bd30579db15a412ade64d53fcc72a5d9a9b8fc35695d3aedd
3
+ metadata.gz: 947dda0ab2fa336611335b258b4eae34e7b60f38083e162fb6bf80d2237ce819
4
+ data.tar.gz: 6744411d6b2a33d5ee54b910ef60652fcb992cbb700a59a31da3eb48c2cb5322
5
5
  SHA512:
6
- metadata.gz: 793918328d63451ef6a6ec3b90b3d2a4082ef2c57e018fa0f84e223defe506c3722f7e2168ef97854fcade562dc115943d9655954fdd9a319a13dca6ec50648b
7
- data.tar.gz: c353256d7854ea1240bfc1e3f6e0ce7b8c76b72404f728c37695f923c4189777463481d57abc55efdce7a0326621a6a61ca9fcb98638e2f2aa279496d126bd20
6
+ metadata.gz: 3e1b51f910a02835ab0612f8be9714dce1dd1024acc3745a4465588447e6e12d8a4bdb2903c66f9c5f8ccc67bb6877ec231ad5979b304aff0ee34e5e4bd1f0a2
7
+ data.tar.gz: e739903401b7787ad66a929ff1f67b0e0b4ff9366571d25ad0349f680bf013adad95be38a1fc71c4f4039174b4ef7ee30764a9786e6b8677597a0d2bd6434749
@@ -1,3 +1,7 @@
1
+ ## 0.7.1 (2020-07-27)
2
+
3
+ - Added `target_version` option to replace database-specific options
4
+
1
5
  ## 0.7.0 (2020-07-22)
2
6
 
3
7
  - Added `check_down` option
data/README.md CHANGED
@@ -45,7 +45,7 @@ Deploy the code, then wrap this step in a safety_assured { ... } block.
45
45
 
46
46
  class RemoveColumn < ActiveRecord::Migration[6.0]
47
47
  def change
48
- safety_assured { remove_column :users, :name, :string }
48
+ safety_assured { remove_column :users, :name }
49
49
  end
50
50
  end
51
51
  ```
@@ -611,7 +611,7 @@ StrongMigrations.disable_check(:add_index)
611
611
 
612
612
  Check the [source code](https://github.com/ankane/strong_migrations/blob/master/lib/strong_migrations.rb) for the list of keys.
613
613
 
614
- ## Down Migrations / Rollbacks [unreleased]
614
+ ## Down Migrations / Rollbacks
615
615
 
616
616
  By default, checks are disabled when migrating down. Enable them with:
617
617
 
@@ -707,11 +707,11 @@ Use the version from your latest migration.
707
707
  If your development database version is different from production, you can specify the production version so the right checks run in development.
708
708
 
709
709
  ```ruby
710
- StrongMigrations.target_postgresql_version = "10"
711
- StrongMigrations.target_mysql_version = "8.0.12"
712
- StrongMigrations.target_mariadb_version = "10.3.2"
710
+ StrongMigrations.target_version = 10 # or "8.0.12", "10.3.2", etc
713
711
  ```
714
712
 
713
+ The major version works well for Postgres, while the full version is recommended for MySQL and MariaDB.
714
+
715
715
  For safety, this option only affects development and test environments. In other environments, the actual server version is always used.
716
716
 
717
717
  ## Analyze Tables
@@ -12,6 +12,17 @@ module StrongMigrations
12
12
  def start_after
13
13
  Time.now.utc.strftime("%Y%m%d%H%M%S")
14
14
  end
15
+
16
+ def target_version
17
+ case ActiveRecord::Base.connection_config[:adapter].to_s
18
+ when /mysql/
19
+ # could try to connect to database and check for MariaDB
20
+ # but this should be fine
21
+ '"8.0.12"'
22
+ else
23
+ "10"
24
+ end
25
+ end
15
26
  end
16
27
  end
17
28
  end
@@ -10,6 +10,10 @@ StrongMigrations.statement_timeout = 1.hour
10
10
  # Outdated statistics can sometimes hurt performance
11
11
  StrongMigrations.auto_analyze = true
12
12
 
13
+ # Set the version of the production database
14
+ # so the right checks are run in development
15
+ # StrongMigrations.target_version = <%= target_version %>
16
+
13
17
  # Add custom checks
14
18
  # StrongMigrations.add_check do |method, args|
15
19
  # if method == :add_index && args[0].to_s == "users"
@@ -17,7 +17,7 @@ module StrongMigrations
17
17
  class << self
18
18
  attr_accessor :auto_analyze, :start_after, :checks, :error_messages,
19
19
  :target_postgresql_version, :target_mysql_version, :target_mariadb_version,
20
- :enabled_checks, :lock_timeout, :statement_timeout, :check_down
20
+ :enabled_checks, :lock_timeout, :statement_timeout, :check_down, :target_version
21
21
  attr_writer :lock_timeout_limit
22
22
  end
23
23
  self.auto_analyze = false
@@ -380,6 +380,7 @@ Then add the foreign key in separate migrations."
380
380
  end
381
381
 
382
382
  def target_version(target_version)
383
+ target_version ||= StrongMigrations.target_version
383
384
  version =
384
385
  if target_version && StrongMigrations.developer_env?
385
386
  target_version.to_s
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-07-23 00:00:00.000000000 Z
13
+ date: 2020-07-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord