actual_db_schema 0.7.3 → 0.7.4

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: ca3780aca89ac715ade8441154b10a78b258514b3daa1d23db1ede9d37d63108
4
- data.tar.gz: cb4ce56d44d5a5c61d20220ab2ead11830db440438e1dd433d0774cdf23aef97
3
+ metadata.gz: 7bae784cf88c546a852fea372e8bcbf1356008bc36c9e63c6ff0e18fb1c06bd6
4
+ data.tar.gz: 0fc13227fd92ecb46f7d10f16d900477115a2ca960c701a2080d19690f1631d3
5
5
  SHA512:
6
- metadata.gz: bf59099adf9a660b934fc65c3573460c4034e59876f0770691019799601217b6eeee29b9f3eda43d1ea837380d6da2bb2930819b81dbc9eb334c6bc2f4e4777c
7
- data.tar.gz: 8c9f16c0bf8f0571f163bcf07a73fe4b62dc4c031897d2d156e234aac3d4ca749a6380a41e983c5dec722d61909b0aaf09caf1f3b2303f885bc76385da6b1039
6
+ metadata.gz: 226db7dc680bb706a73048c1fec3e52685a1e36ac5d5e2cef82511080234e1cc6b789cb5266ea101669462205823ec565da9b059cc7d4b0752fc4f600f0cfbe2
7
+ data.tar.gz: 47c936d8bb2cddf627dbb04ab8d3993e71a960363d4472c9ef9fa4b2102b89789fea7257333b6b91e38ffe1a288c52b5e72ef619377c97276684a0f46dd04ee1
data/Appraisals CHANGED
@@ -6,3 +6,9 @@
6
6
  gem "activesupport", "~> #{version}.0"
7
7
  end
8
8
  end
9
+
10
+ appraise "rails.edge" do
11
+ gem "rails", ">= 7.2.0.beta"
12
+ gem "activerecord", ">= 7.2.0.beta"
13
+ gem "activesupport", ">= 7.2.0.beta"
14
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.7.4] - 2024-06-06
2
+ - Rails 7.2 support added
3
+ - Rails 6.0 support added
4
+
1
5
  ## [0.7.3] - 2024-04-06
2
6
  - add multipe databases support
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actual_db_schema (0.7.3)
4
+ actual_db_schema (0.7.4)
5
5
  activerecord (>= 6.0.0)
6
6
  activesupport (>= 6.0.0)
7
7
  csv
@@ -133,6 +133,8 @@ GEM
133
133
  net-smtp (0.4.0)
134
134
  net-protocol
135
135
  nio4r (2.5.9)
136
+ nokogiri (1.15.4-arm64-darwin)
137
+ racc (~> 1.4)
136
138
  nokogiri (1.15.4-x86_64-darwin)
137
139
  racc (~> 1.4)
138
140
  nokogiri (1.15.4-x86_64-linux)
@@ -204,6 +206,7 @@ GEM
204
206
  parser (>= 3.2.1.0)
205
207
  ruby-progressbar (1.13.0)
206
208
  ruby2_keywords (0.0.5)
209
+ sqlite3 (1.6.8-arm64-darwin)
207
210
  sqlite3 (1.6.8-x86_64-darwin)
208
211
  sqlite3 (1.6.8-x86_64-linux)
209
212
  stringio (3.0.8)
@@ -219,6 +222,7 @@ GEM
219
222
  zeitwerk (2.6.12)
220
223
 
221
224
  PLATFORMS
225
+ arm64-darwin-23
222
226
  x86_64-darwin-20
223
227
  x86_64-darwin-22
224
228
  x86_64-linux
data/README.md CHANGED
@@ -52,7 +52,7 @@ If you cannot commit changes to the repo or Gemfile, consider the local Gemfile
52
52
 
53
53
  ## Usage
54
54
 
55
- Just run `rails db:migrate` inside the current branch.
55
+ Just run `rails db:migrate` inside the current branch. It will roll back all phantom migrations for all configured databases in your `database.yml.`
56
56
 
57
57
  > [!WARNING]
58
58
  > This solution implies that all migrations are reversible. The irreversible migrations should be solved manually. At the moment, the gem ignores them. You will see warnings in the terminal for each irreversible migrations.
@@ -75,6 +75,26 @@ To release a new version do the following in the order:
75
75
  - make the commit and push;
76
76
  - run `bundle exec rake release`. This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
77
 
78
+ ### Running Tests with Specific Rails Versions
79
+
80
+ The following versions can be specifically tested using Appraisal
81
+ - 6.0
82
+ - 6.1
83
+ - 7.0
84
+ - 7.1
85
+ - edge
86
+
87
+ To run tests with a specific version of Rails using Appraisal:
88
+ - Run all tests with Rails 6.0:
89
+ ```sh
90
+ bundle exec appraisal rails.6.0 rake test
91
+ - Run tests for a specific file:
92
+ ```sh
93
+ bundle exec appraisal rails.6.0 rake test TEST=test/rake_task_test.rb
94
+ - Run a specific test:
95
+ ```sh
96
+ bundle exec appraisal rails.6.0 rake test TEST=test/rake_task_test.rb TESTOPTS="--name=/db::db:rollback_branches#test_0003_keeps/"
97
+
78
98
  ## Contributing
79
99
 
80
100
  Bug reports and pull requests are welcome on GitHub at https://github.com/widefix/actual_db_schema. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/widefix/actual_db_schema/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "activerecord", ">= 7.2.0.beta"
8
+ gem "activesupport", ">= 7.2.0.beta"
9
+ gem "minitest", "~> 5.0"
10
+ gem "rake"
11
+ gem "rubocop", "~> 1.21"
12
+ gem "rails", ">= 7.2.0.beta"
13
+ gem "sqlite3"
14
+
15
+ gemspec path: "../"
@@ -19,10 +19,19 @@ module ActualDbSchema
19
19
  end
20
20
 
21
21
  def context
22
- @context ||=
23
- ActiveRecord::Base.connection.migration_context.tap do |c|
24
- c.extend(ActualDbSchema::Patches::MigrationContext)
25
- end
22
+ @context ||= fetch_migration_context.tap do |c|
23
+ c.extend(ActualDbSchema::Patches::MigrationContext)
24
+ end
25
+ end
26
+
27
+ def fetch_migration_context
28
+ ar_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
29
+ if ar_version >= Gem::Version.new("7.2.0") ||
30
+ (ar_version >= Gem::Version.new("7.1.0") && ar_version.prerelease?)
31
+ ActiveRecord::Base.connection_pool.migration_context
32
+ else
33
+ ActiveRecord::Base.connection.migration_context
34
+ end
26
35
  end
27
36
  end
28
37
  end
@@ -19,11 +19,20 @@ module ActualDbSchema
19
19
  puts "\nPhantom migrations\n\n"
20
20
  puts "Below is a list of irrelevant migrations executed in unmerged branches."
21
21
  puts "To bring your database schema up to date, the migrations marked as \"up\" should be rolled back."
22
- puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n"
22
+ database_path = db_config[:database]
23
+ puts "\ndatabase: #{database_path}\n\n"
23
24
  puts header.join(" ")
24
25
  puts "-" * separator_width
25
26
  end
26
27
 
28
+ def db_config
29
+ if ActiveRecord::Base.respond_to?(:connection_db_config)
30
+ ActiveRecord::Base.connection_db_config.configuration_hash
31
+ else
32
+ ActiveRecord::Base.connection_config
33
+ end
34
+ end
35
+
27
36
  def separator_width
28
37
  header.map(&:length).sum + (header.size - 1) * 2
29
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActualDbSchema
4
- VERSION = "0.7.3"
4
+ VERSION = "0.7.4"
5
5
  end
@@ -50,7 +50,11 @@ module ActualDbSchema
50
50
  end
51
51
 
52
52
  def self.migrations_paths
53
- ActiveRecord::Base.connection_db_config.migrations_paths
53
+ if ActiveRecord::Base.respond_to?(:connection_db_config)
54
+ ActiveRecord::Base.connection_db_config.migrations_paths
55
+ else
56
+ ActiveRecord::Base.connection_config[:migrations_paths]
57
+ end
54
58
  end
55
59
 
56
60
  def self.migration_filename(fullpath)
@@ -60,7 +64,8 @@ module ActualDbSchema
60
64
  def self.for_each_db_connection
61
65
  configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
62
66
  configs.each do |db_config|
63
- ActiveRecord::Base.establish_connection(db_config)
67
+ config = db_config.respond_to?(:config) ? db_config.config : db_config
68
+ ActiveRecord::Base.establish_connection(config)
64
69
  yield
65
70
  end
66
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actual_db_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Kaleshka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-06 00:00:00.000000000 Z
11
+ date: 2024-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -131,6 +131,7 @@ files:
131
131
  - gemfiles/rails.6.1.gemfile
132
132
  - gemfiles/rails.7.0.gemfile
133
133
  - gemfiles/rails.7.1.gemfile
134
+ - gemfiles/rails.edge.gemfile
134
135
  - lib/actual_db_schema.rb
135
136
  - lib/actual_db_schema/commands/base.rb
136
137
  - lib/actual_db_schema/commands/list.rb
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  - !ruby/object:Gem::Version
167
168
  version: '0'
168
169
  requirements: []
169
- rubygems_version: 3.3.3
170
+ rubygems_version: 3.3.26
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Keep your DB and schema.rb consistent in dev branches.