actual_db_schema 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/gemfiles/rails.6.0.gemfile +1 -0
- data/gemfiles/rails.6.1.gemfile +1 -0
- data/gemfiles/rails.7.0.gemfile +1 -0
- data/gemfiles/rails.7.1.gemfile +1 -0
- data/lib/actual_db_schema/commands/base.rb +0 -4
- data/lib/actual_db_schema/patches/migration_context.rb +0 -1
- data/lib/actual_db_schema/store.rb +1 -0
- data/lib/actual_db_schema/version.rb +1 -1
- data/lib/actual_db_schema.rb +30 -1
- data/lib/tasks/db.rake +8 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3780aca89ac715ade8441154b10a78b258514b3daa1d23db1ede9d37d63108
|
4
|
+
data.tar.gz: cb4ce56d44d5a5c61d20220ab2ead11830db440438e1dd433d0774cdf23aef97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf59099adf9a660b934fc65c3573460c4034e59876f0770691019799601217b6eeee29b9f3eda43d1ea837380d6da2bb2930819b81dbc9eb334c6bc2f4e4777c
|
7
|
+
data.tar.gz: 8c9f16c0bf8f0571f163bcf07a73fe4b62dc4c031897d2d156e234aac3d4ca749a6380a41e983c5dec722d61909b0aaf09caf1f3b2303f885bc76385da6b1039
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -48,6 +48,8 @@ And then execute:
|
|
48
48
|
|
49
49
|
$ bundle install
|
50
50
|
|
51
|
+
If you cannot commit changes to the repo or Gemfile, consider the local Gemfile installation described in [this post](https://blog.widefix.com/personal-gemfile-for-development/).
|
52
|
+
|
51
53
|
## Usage
|
52
54
|
|
53
55
|
Just run `rails db:migrate` inside the current branch.
|
data/gemfiles/rails.6.0.gemfile
CHANGED
data/gemfiles/rails.6.1.gemfile
CHANGED
data/gemfiles/rails.7.0.gemfile
CHANGED
data/gemfiles/rails.7.1.gemfile
CHANGED
@@ -9,10 +9,6 @@ module ActualDbSchema
|
|
9
9
|
raise "ActualDbSchema is disabled. Set ActualDbSchema.config[:enabled] = true to enable it."
|
10
10
|
end
|
11
11
|
|
12
|
-
if ActiveRecord::Migration.current_version >= 6
|
13
|
-
ActiveRecord::Tasks::DatabaseTasks.raise_for_multi_db(command: "db:rollback_branches")
|
14
|
-
end
|
15
|
-
|
16
12
|
call_impl
|
17
13
|
end
|
18
14
|
|
@@ -5,7 +5,6 @@ module ActualDbSchema
|
|
5
5
|
# Add new command to roll back the phantom migrations
|
6
6
|
module MigrationContext
|
7
7
|
def rollback_branches
|
8
|
-
ActualDbSchema.failed = []
|
9
8
|
migrations.reverse_each do |migration|
|
10
9
|
migrator = down_migrator_for(migration)
|
11
10
|
migrator.extend(ActualDbSchema::Patches::Migrator)
|
data/lib/actual_db_schema.rb
CHANGED
@@ -29,12 +29,41 @@ module ActualDbSchema
|
|
29
29
|
}
|
30
30
|
|
31
31
|
def self.migrated_folder
|
32
|
-
|
32
|
+
migrated_folders.first
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.migrated_folders
|
36
|
+
return [default_migrated_folder] unless migrations_paths
|
37
|
+
|
38
|
+
Array(migrations_paths).map do |path|
|
39
|
+
if path.end_with?("db/migrate")
|
40
|
+
default_migrated_folder
|
41
|
+
else
|
42
|
+
postfix = path.split("/").last
|
43
|
+
Rails.root.join("tmp", "migrated_#{postfix}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.default_migrated_folder
|
49
|
+
Rails.root.join("tmp", "migrated")
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.migrations_paths
|
53
|
+
ActiveRecord::Base.connection_db_config.migrations_paths
|
33
54
|
end
|
34
55
|
|
35
56
|
def self.migration_filename(fullpath)
|
36
57
|
fullpath.split("/").last
|
37
58
|
end
|
59
|
+
|
60
|
+
def self.for_each_db_connection
|
61
|
+
configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
|
62
|
+
configs.each do |db_config|
|
63
|
+
ActiveRecord::Base.establish_connection(db_config)
|
64
|
+
yield
|
65
|
+
end
|
66
|
+
end
|
38
67
|
end
|
39
68
|
|
40
69
|
ActiveRecord::MigrationProxy.prepend(ActualDbSchema::Patches::MigrationProxy)
|
data/lib/tasks/db.rake
CHANGED
@@ -3,13 +3,18 @@
|
|
3
3
|
namespace :db do
|
4
4
|
desc "Rollback migrations that were run inside not a merged branch."
|
5
5
|
task rollback_branches: :load_config do
|
6
|
-
ActualDbSchema
|
6
|
+
ActualDbSchema.failed = []
|
7
|
+
ActualDbSchema.for_each_db_connection do
|
8
|
+
ActualDbSchema::Commands::Rollback.new.call
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
desc "List all phantom migrations - non-relevant migrations that were run inside not a merged branch."
|
10
13
|
task phantom_migrations: :load_config do
|
11
|
-
ActualDbSchema
|
14
|
+
ActualDbSchema.for_each_db_connection do
|
15
|
+
ActualDbSchema::Commands::List.new.call
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
|
-
task
|
19
|
+
task "schema:dump" => :rollback_branches
|
15
20
|
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.
|
4
|
+
version: 0.7.3
|
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-
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.3.3
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Keep your DB and schema.rb consistent in dev branches.
|