actual_db_schema 0.2.0 → 0.3.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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/actual_db_schema/version.rb +1 -1
- data/lib/tasks/db.rake +14 -4
- 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: b63fb97832086a404eb2ff18cda0efa99659c8b4b836128130f15e72f20a77b2
|
4
|
+
data.tar.gz: 7d5e45d844564dc33377837ebc926137a6ef1e72765ac2dd91dbded0c45c2a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5372a2858523be0bdfdf3487c83dab1ebea97be8c5f8875d6cec3094f017a802d9b141870de3c2877423fc071ac2f55ceccaa5136cd81eda77d94c3757fcdd
|
7
|
+
data.tar.gz: 7e71a858de75c5fb314da5d55d06a07cdbfde7919cbe016cdd7c3ab657b72ae892557ef8552f2e248a70ffe5e6484b750073b5d9a7ad1a66e7925220326fd5d8
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
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 =
|
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.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:
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|