actual_db_schema 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba9797cc49da84c28977ef23e93bb8f76a34176614fa12deb3f2e7787dcb880e
4
- data.tar.gz: 502f59630d933d643df14de7e50c72c84b4fe00bf8ff0034bb01c604e8d2c343
3
+ metadata.gz: b63fb97832086a404eb2ff18cda0efa99659c8b4b836128130f15e72f20a77b2
4
+ data.tar.gz: 7d5e45d844564dc33377837ebc926137a6ef1e72765ac2dd91dbded0c45c2a38
5
5
  SHA512:
6
- metadata.gz: d0e6ad5b607a3ff67243b5e2ec8d8fa6863068f0e63118de3a2dbda3922892e5c73e036c1c0da7693a7ab427fe923fe82b214adb8640352848c87545f1e8862d
7
- data.tar.gz: 8a47aec7467625c6e68e8d35fd2f5035863d8556e7da9e6cce13931d27a06acae823e2beb186286cc62eab0c636e80af866ffcac0e1fab8c3667c89fc76b962c
6
+ metadata.gz: 7f5372a2858523be0bdfdf3487c83dab1ebea97be8c5f8875d6cec3094f017a802d9b141870de3c2877423fc071ac2f55ceccaa5136cd81eda77d94c3757fcdd
7
+ data.tar.gz: 7e71a858de75c5fb314da5d55d06a07cdbfde7919cbe016cdd7c3ab657b72ae892557ef8552f2e248a70ffe5e6484b750073b5d9a7ad1a66e7925220326fd5d8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.0] - 2023-01-23
2
+
3
+ - add Rails 6 and older support
4
+
1
5
  ## [0.2.0] - 2022-10-19
2
6
 
3
7
  - Catch exceptions about irreversible migrations and show a warning
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actual_db_schema (0.2.0)
4
+ actual_db_schema (0.3.0)
5
5
  activerecord
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/actual_db_schema.svg)](https://badge.fury.io/rb/actual_db_schema)
2
+
1
3
  # ActualDbSchema
2
4
 
3
5
  Keep Rails DB schema consistent while switching between branches with no additional actions.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActualDbSchema
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/tasks/db.rake CHANGED
@@ -40,7 +40,7 @@ module ActualDbSchema
40
40
  module MigrationContextPatch
41
41
  def rollback_branches
42
42
  migrations.each do |migration|
43
- migrator = ActiveRecord::Migrator.new(:down, [migration], schema_migration, migration.version)
43
+ migrator = down_migrator_for(migration)
44
44
  migrator.extend(ActualDbSchema::MigratorPatch)
45
45
  migrator.migrate
46
46
  rescue StandardError => e
@@ -52,13 +52,21 @@ module ActualDbSchema
52
52
 
53
53
  private
54
54
 
55
+ def down_migrator_for(migration)
56
+ if ActiveRecord::Migration.current_version < 6
57
+ ActiveRecord::Migrator.new(:down, [migration], migration.version)
58
+ else
59
+ ActiveRecord::Migrator.new(:down, [migration], schema_migration, migration.version)
60
+ end
61
+ end
62
+
55
63
  def migration_files
56
64
  paths = Array(migrations_paths)
57
65
  current_branch_files = Dir[*paths.flat_map { |path| "#{path}/**/[0-9]*_*.rb" }]
58
66
  other_branches_files = Dir["#{migrated_folder}/**/[0-9]*_*.rb"]
59
67
 
60
- current_branch_file_names = current_branch_files.map { migration_filename(_1) }
61
- other_branches_files.reject { migration_filename(_1).in?(current_branch_file_names) }
68
+ current_branch_file_names = current_branch_files.map { |f| migration_filename(f) }
69
+ other_branches_files.reject { |f| migration_filename(f).in?(current_branch_file_names) }
62
70
  end
63
71
  end
64
72
  end
@@ -68,7 +76,9 @@ ActiveRecord::MigrationProxy.prepend(ActualDbSchema::MigrationProxyPatch)
68
76
  namespace :db do
69
77
  desc "Rollback migrations that were run inside not a merged branch."
70
78
  task rollback_branches: :load_config do
71
- ActiveRecord::Tasks::DatabaseTasks.raise_for_multi_db(command: "db:rollback_branches")
79
+ if ActiveRecord::Migration.current_version >= 6
80
+ ActiveRecord::Tasks::DatabaseTasks.raise_for_multi_db(command: "db:rollback_branches")
81
+ end
72
82
 
73
83
  context = ActiveRecord::Base.connection.migration_context
74
84
  context.extend(ActualDbSchema::MigrationContextPatch)
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Kaleshka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-19 00:00:00.000000000 Z
11
+ date: 2023-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord