actual_db_schema 0.7.1 → 0.7.3
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 +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -0
- data/actual_db_schema.gemspec +5 -6
- 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 +9 -10
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
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
actual_db_schema (0.7.
|
4
|
+
actual_db_schema (0.7.3)
|
5
5
|
activerecord (>= 6.0.0)
|
6
6
|
activesupport (>= 6.0.0)
|
7
7
|
csv
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
concurrent-ruby (1.2.2)
|
94
94
|
connection_pool (2.4.1)
|
95
95
|
crass (1.0.6)
|
96
|
-
csv (3.
|
96
|
+
csv (3.3.0)
|
97
97
|
date (3.3.3)
|
98
98
|
debug (1.8.0)
|
99
99
|
irb (>= 1.5.0)
|
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/actual_db_schema.gemspec
CHANGED
@@ -8,20 +8,19 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Andrei Kaleshka"]
|
9
9
|
spec.email = ["ka8725@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "Keep your DB
|
11
|
+
spec.summary = "Keep your DB and schema.rb consistent in dev branches."
|
12
12
|
spec.description = <<~DESC
|
13
|
-
|
14
|
-
|
15
|
-
Install this gem and forget about that issue by running the standard rake db:migrate.
|
13
|
+
Wipe out inconsistent DB and schema.rb when switching branches.
|
14
|
+
Just install this gem and use the standard rake db:migrate command.
|
16
15
|
DESC
|
17
|
-
spec.homepage = "https://
|
16
|
+
spec.homepage = "https://blog.widefix.com/actual-db-schema/"
|
18
17
|
spec.license = "MIT"
|
19
18
|
spec.required_ruby_version = ">= 2.7.0"
|
20
19
|
|
21
20
|
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
22
21
|
|
23
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
-
spec.metadata["source_code_uri"] =
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/widefix/actual_db_schema"
|
25
24
|
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
26
25
|
|
27
26
|
# Specify which files should be added to the gem when it is released.
|
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
|
@@ -109,9 +109,8 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: |
|
112
|
-
|
113
|
-
|
114
|
-
Install this gem and forget about that issue by running the standard rake db:migrate.
|
112
|
+
Wipe out inconsistent DB and schema.rb when switching branches.
|
113
|
+
Just install this gem and use the standard rake db:migrate command.
|
115
114
|
email:
|
116
115
|
- ka8725@gmail.com
|
117
116
|
executables: []
|
@@ -145,13 +144,13 @@ files:
|
|
145
144
|
- lib/railtie.rb
|
146
145
|
- lib/tasks/db.rake
|
147
146
|
- sig/actual_db_schema.rbs
|
148
|
-
homepage: https://
|
147
|
+
homepage: https://blog.widefix.com/actual-db-schema/
|
149
148
|
licenses:
|
150
149
|
- MIT
|
151
150
|
metadata:
|
152
|
-
homepage_uri: https://
|
151
|
+
homepage_uri: https://blog.widefix.com/actual-db-schema/
|
153
152
|
source_code_uri: https://github.com/widefix/actual_db_schema
|
154
|
-
changelog_uri: https://
|
153
|
+
changelog_uri: https://blog.widefix.com/actual-db-schema//blob/main/CHANGELOG.md
|
155
154
|
post_install_message:
|
156
155
|
rdoc_options: []
|
157
156
|
require_paths:
|
@@ -167,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
166
|
- !ruby/object:Gem::Version
|
168
167
|
version: '0'
|
169
168
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.3.3
|
171
170
|
signing_key:
|
172
171
|
specification_version: 4
|
173
|
-
summary: Keep your DB
|
172
|
+
summary: Keep your DB and schema.rb consistent in dev branches.
|
174
173
|
test_files: []
|