actual_db_schema 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +10 -10
- data/README.md +2 -0
- data/lib/actual_db_schema/version.rb +1 -1
- data/lib/tasks/db.rake +15 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f452edc8daa863317285713926ed63c23141523bb4072d5d92efaf512c95023
|
4
|
+
data.tar.gz: 21d4189566b38353dc93f5f58acec5a343ef8553736f8e119263b4606672082f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a591d53c12d6d26993ff7ffaebf12ee4fc2cfd183a04bae10f32d1f7b514dcbdc0b012349f0b2f6fc392d724fcba1ecc6981a6f8f5f0c69222eb0c91290f1397
|
7
|
+
data.tar.gz: c9251df1909fbd42a722ae7f62b3dfbcf40ff5cc669fc3a6eac992a322d91fd96c31d476a6adac0324bf21d9420e2f91bd5f08c910fb833dfb57841af7e84e73
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
actual_db_schema (0.
|
4
|
+
actual_db_schema (0.4.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (7.0.
|
11
|
-
activesupport (= 7.0.
|
12
|
-
activerecord (7.0.
|
13
|
-
activemodel (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
10
|
+
activemodel (7.0.6)
|
11
|
+
activesupport (= 7.0.6)
|
12
|
+
activerecord (7.0.6)
|
13
|
+
activemodel (= 7.0.6)
|
14
|
+
activesupport (= 7.0.6)
|
15
|
+
activesupport (7.0.6)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
19
19
|
tzinfo (~> 2.0)
|
20
20
|
ast (2.4.2)
|
21
|
-
concurrent-ruby (1.
|
22
|
-
i18n (1.
|
21
|
+
concurrent-ruby (1.2.2)
|
22
|
+
i18n (1.14.1)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
24
|
json (2.6.2)
|
25
25
|
minitest (5.16.3)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
rubocop-ast (1.21.0)
|
44
44
|
parser (>= 3.1.1.0)
|
45
45
|
ruby-progressbar (1.11.0)
|
46
|
-
tzinfo (2.0.
|
46
|
+
tzinfo (2.0.6)
|
47
47
|
concurrent-ruby (~> 1.0)
|
48
48
|
unicode-display_width (2.3.0)
|
49
49
|
|
data/README.md
CHANGED
data/lib/tasks/db.rake
CHANGED
@@ -39,8 +39,8 @@ module ActualDbSchema
|
|
39
39
|
# Add new command to roll back the phantom migrations
|
40
40
|
module MigrationContextPatch
|
41
41
|
def rollback_branches
|
42
|
-
migrations.
|
43
|
-
migrator =
|
42
|
+
migrations.reverse_each do |migration|
|
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(
|
61
|
-
other_branches_files.reject { migration_filename(
|
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::
|
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.
|
4
|
+
version: 0.4.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:
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|