actual_db_schema 0.7.8 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d2364e9f753a0515b61cfc7598a8479af8e6819a54ce9c103b44572bd09f7a2
4
- data.tar.gz: 9d0e8b6a73e4f94b9beeb73d799053be6745b17804f93acbf3f0e09c6a7142f0
3
+ metadata.gz: 43a6d3a4c89ea984fe7b4cbc6160a9f459951bac207d2592b609ae0a7606fd76
4
+ data.tar.gz: ac2dcb733bb87bdf8dcf5daa250eb386e0ac15f99297d0feb53815e308fb3915
5
5
  SHA512:
6
- metadata.gz: 32b066503c2e9aa938552be473b4f8959022d022de6c743791f885781f6a1e585c83d1a1e635d78ffa378fdd0de828c5496c7f55c43638e16319aac74b2d39ac
7
- data.tar.gz: 329e032b35b735a1b5fc0a3ffd4c7be8ebb9d98aca4469012321faa562cb6f46455996ad9bcc47d271ab2dd276ca5d5abad15af9b3da77b08c2612cc9936ebb1
6
+ metadata.gz: 1bd9b3d3ed5145aacc2d0a481742dc3a45e707257dc3290de245ca4e6ce8db26aaad75619bb0212273aedc6dc30c833e0e604d84c5a1711ea0d1bf8d0cef0dc2
7
+ data.tar.gz: bbc183547eeb23566c326405519120af7e4e1aea2525ade5c7f8711985d90b6d3d142322bcc19b955a1605f58074420c28657646a16be8c667d47aeae2531ebc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [0.8.0] - 2024-12-30
2
+ - Enhanced Console Visibility: Automatically rolled-back phantom migrations now provide clearer and more visible logs in the console
3
+ - Git Hooks for Branch Management: Introduced hooks that automatically rollback phantom migrations after checking out a branch. Additionally, the schema migration rake task can now be executed automatically upon branch checkout
4
+ - Temporary Folder Cleanup: Rolled-back phantom migrations are now automatically deleted from the temporary folder after rollback
5
+ - Acronym Support in Phantom Migration Names: Resolved an issue where phantom migrations with acronyms in their names, defined in other branches, couldn't be rolled back automatically. These are now handled seamlessly
6
+
7
+ ## [0.7.9] - 2024-09-07
8
+ - Don't stop if a phantom migration rollback fails
9
+ - Improve failed rollback of phantom migrations report
10
+
1
11
  ## [0.7.8] - 2024-08-07
2
12
  - Make UI working without assets pipeline
3
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actual_db_schema (0.7.8)
4
+ actual_db_schema (0.8.0)
5
5
  activerecord
6
6
  activesupport
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.3.0)
96
+ csv (3.3.2)
97
97
  date (3.3.3)
98
98
  debug (1.8.0)
99
99
  irb (>= 1.5.0)
data/README.md CHANGED
@@ -110,6 +110,40 @@ Add the following line to your initializer file (`config/initializers/actual_db_
110
110
  ActualDbSchema.config[:auto_rollback_disabled] = true
111
111
  ```
112
112
 
113
+ ## Automatic Phantom Migration Rollback On Branch Switch
114
+
115
+ By default, the automatic rollback of migrations on branch switch is disabled. If you prefer to automatically rollback phantom migrations whenever you switch branches with `git checkout`, you can enable it in two ways:
116
+
117
+ ### 1. Using Environment Variable
118
+
119
+ Set the environment variable `ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED` to `true`:
120
+
121
+ ```sh
122
+ export ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED=true
123
+ ```
124
+
125
+ ### 2. Using Initializer
126
+ Add the following line to your initializer file (`config/initializers/actual_db_schema.rb`):
127
+
128
+ ```ruby
129
+ ActualDbSchema.config[:git_hooks_enabled] = true
130
+ ```
131
+
132
+ ### Installing the Post-Checkout Hook
133
+ After enabling Git hooks in your configuration, run the rake task to install the post-checkout hook:
134
+
135
+ ```sh
136
+ rake actual_db_schema:install_git_hooks
137
+ ```
138
+
139
+ This task will prompt you to choose one of the three options:
140
+
141
+ 1. Rollback phantom migrations with `db:rollback_branches`
142
+ 2. Migrate up to the latest schema with `db:migrate`
143
+ 3. Skip installing git hook
144
+
145
+ Based on your selection, a post-checkout hook will be installed or updated in your `.git/hooks` folder.
146
+
113
147
  ## Development
114
148
 
115
149
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -122,7 +156,8 @@ To release a new version do the following in the order:
122
156
  - update the CHANGELOG;
123
157
  - `bundle install` to update `Gemfile.lock`;
124
158
  - make the commit and push;
125
- - run `bundle exec rake release`. This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
159
+ - run `bundle exec rake release`. This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org);
160
+ - [announce the new release on GitHub](https://github.com/widefix/actual_db_schema/releases).
126
161
 
127
162
  ### Running Tests with Specific Rails Versions
128
163
 
@@ -44,6 +44,18 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency "rails"
45
45
  spec.add_development_dependency "sqlite3"
46
46
 
47
+ spec.post_install_message = <<~MSG
48
+ Thank you for installing ActualDbSchema!
49
+
50
+ To enable automatic rollback of phantom migrations when switching branches, follow these steps:
51
+ 1. Set `export ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED=true` in your environment, OR
52
+ add `ActualDbSchema.config[:git_hooks_enabled] = true` to your initializer.
53
+ 2. Run `rake actual_db_schema:install_git_hooks` to install the post-checkout Git hook.
54
+
55
+ For more information, see the README.
56
+
57
+ MSG
58
+
47
59
  # For more information and examples about making a new gem, check out our
48
60
  # guide at: https://bundler.io/guides/creating_gem.html
49
61
  end
@@ -4,6 +4,9 @@ module ActualDbSchema
4
4
  module Commands
5
5
  # Rolls back all phantom migrations
6
6
  class Rollback < Base
7
+ include ActualDbSchema::OutputFormatter
8
+ include ActionView::Helpers::TextHelper
9
+
7
10
  def initialize(context, manual_mode: false)
8
11
  @manual_mode = manual_mode || manual_mode_default?
9
12
  super(context)
@@ -12,15 +15,58 @@ module ActualDbSchema
12
15
  private
13
16
 
14
17
  def call_impl
15
- context.rollback_branches(manual_mode: @manual_mode)
18
+ rolled_back = context.rollback_branches(manual_mode: @manual_mode)
19
+
20
+ return unless rolled_back
21
+
22
+ ActualDbSchema.failed.empty? ? print_success : print_error
23
+ end
24
+
25
+ def print_success
26
+ puts colorize("[ActualDbSchema] All phantom migrations rolled back successfully! 🎉", :green)
27
+ end
28
+
29
+ def print_error
30
+ header_message = <<~HEADER
31
+ #{ActualDbSchema.failed.count} phantom migration(s) could not be rolled back automatically.
32
+
33
+ Try these steps to fix and move forward:
34
+ 1. Ensure the migrations are reversible (define #up and #down methods or use #reversible).
35
+ 2. If the migration references code or tables from another branch, restore or remove them.
36
+ 3. Once fixed, run `rails db:migrate` again.
16
37
 
17
- return if ActualDbSchema.failed.empty?
38
+ Below are the details of the problematic migrations:
39
+ HEADER
40
+
41
+ print_error_summary("#{header_message}\n#{failed_migrations_list}")
42
+ end
43
+
44
+ def failed_migrations_list
45
+ ActualDbSchema.failed.map.with_index(1) do |failed, index|
46
+ <<~MIGRATION
47
+ #{colorize("Migration ##{index}:", :yellow)}
48
+ File: #{failed.short_filename}
49
+ Branch: #{failed.branch}
50
+ MIGRATION
51
+ end.join("\n")
52
+ end
53
+
54
+ def print_error_summary(content)
55
+ width = 100
56
+ indent = 4
57
+ gem_name = "ActualDbSchema"
58
+
59
+ puts colorize("╔═ [#{gem_name}] #{"═" * (width - gem_name.length - 5)}╗", :red)
60
+ print_wrapped_content(content, width, indent)
61
+ puts colorize("╚#{"═" * width}╝", :red)
62
+ end
18
63
 
19
- puts ""
20
- puts "[ActualDbSchema] Irreversible migrations were found from other branches. Roll them back or fix manually:"
21
- puts ""
22
- puts ActualDbSchema.failed.map { |migration| "- #{migration.filename}" }.join("\n")
23
- puts ""
64
+ def print_wrapped_content(content, width, indent)
65
+ usable_width = width - indent - 4
66
+ wrapped_content = word_wrap(content, line_width: usable_width)
67
+ wrapped_content.each_line do |line|
68
+ puts "#{" " * indent}#{line.chomp}"
69
+ end
24
70
  end
25
71
 
26
72
  def manual_mode_default?
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActualDbSchema
4
+ FailedMigration = Struct.new(:migration, :exception, :branch, keyword_init: true) do
5
+ def filename
6
+ migration.filename
7
+ end
8
+
9
+ def short_filename
10
+ migration.filename.sub(File.join(Rails.root, "/"), "")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,184 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+
5
+ module ActualDbSchema
6
+ # Handles the installation of a git post-checkout hook that rolls back phantom migrations when switching branches
7
+ class GitHooks # rubocop:disable Metrics/ClassLength
8
+ include ActualDbSchema::OutputFormatter
9
+
10
+ POST_CHECKOUT_MARKER_START = "# >>> BEGIN ACTUAL_DB_SCHEMA"
11
+ POST_CHECKOUT_MARKER_END = "# <<< END ACTUAL_DB_SCHEMA"
12
+
13
+ POST_CHECKOUT_HOOK_ROLLBACK = <<~BASH
14
+ #{POST_CHECKOUT_MARKER_START}
15
+ # ActualDbSchema post-checkout hook (ROLLBACK)
16
+ # Runs db:rollback_branches on branch checkout.
17
+
18
+ if [ -f ./bin/rails ]; then
19
+ if [ -n "$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED" ]; then
20
+ GIT_HOOKS_ENABLED="$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"
21
+ else
22
+ GIT_HOOKS_ENABLED=$(./bin/rails runner "puts ActualDbSchema.config[:git_hooks_enabled]" 2>/dev/null)
23
+ fi
24
+
25
+ if [ "$GIT_HOOKS_ENABLED" == "true" ]; then
26
+ ./bin/rails db:rollback_branches
27
+ fi
28
+ fi
29
+ #{POST_CHECKOUT_MARKER_END}
30
+ BASH
31
+
32
+ POST_CHECKOUT_HOOK_MIGRATE = <<~BASH
33
+ #{POST_CHECKOUT_MARKER_START}
34
+ # ActualDbSchema post-checkout hook (MIGRATE)
35
+ # Runs db:migrate on branch checkout.
36
+
37
+ if [ -f ./bin/rails ]; then
38
+ if [ -n "$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED" ]; then
39
+ GIT_HOOKS_ENABLED="$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"
40
+ else
41
+ GIT_HOOKS_ENABLED=$(./bin/rails runner "puts ActualDbSchema.config[:git_hooks_enabled]" 2>/dev/null)
42
+ fi
43
+
44
+ if [ "$GIT_HOOKS_ENABLED" == "true" ]; then
45
+ ./bin/rails db:migrate
46
+ fi
47
+ fi
48
+ #{POST_CHECKOUT_MARKER_END}
49
+ BASH
50
+
51
+ def initialize(strategy: :rollback)
52
+ @strategy = strategy
53
+ end
54
+
55
+ def install_post_checkout_hook
56
+ return unless git_hooks_enabled?
57
+ return unless hooks_directory_present?
58
+
59
+ if File.exist?(hook_path)
60
+ handle_existing_hook
61
+ else
62
+ create_new_hook
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ def hook_code
69
+ @strategy == :migrate ? POST_CHECKOUT_HOOK_MIGRATE : POST_CHECKOUT_HOOK_ROLLBACK
70
+ end
71
+
72
+ def hooks_dir
73
+ @hooks_dir ||= Rails.root.join(".git", "hooks")
74
+ end
75
+
76
+ def hook_path
77
+ @hook_path ||= hooks_dir.join("post-checkout")
78
+ end
79
+
80
+ def git_hooks_enabled?
81
+ return true if ActualDbSchema.config[:git_hooks_enabled]
82
+
83
+ puts colorize("[ActualDbSchema] Git hooks are disabled in configuration. Skipping installation.", :gray)
84
+ end
85
+
86
+ def hooks_directory_present?
87
+ return true if Dir.exist?(hooks_dir)
88
+
89
+ puts colorize("[ActualDbSchema] .git/hooks directory not found. Please ensure this is a Git repository.", :gray)
90
+ end
91
+
92
+ def handle_existing_hook
93
+ return update_hook if markers_exist?
94
+ return install_hook if safe_install?
95
+
96
+ show_manual_install_instructions
97
+ end
98
+
99
+ def create_new_hook
100
+ contents = <<~BASH
101
+ #!/usr/bin/env bash
102
+
103
+ #{hook_code}
104
+ BASH
105
+
106
+ write_hook_file(contents)
107
+ print_success
108
+ end
109
+
110
+ def markers_exist?
111
+ contents = File.read(hook_path)
112
+ contents.include?(POST_CHECKOUT_MARKER_START) && contents.include?(POST_CHECKOUT_MARKER_END)
113
+ end
114
+
115
+ def update_hook
116
+ contents = File.read(hook_path)
117
+ new_contents = replace_marker_contents(contents)
118
+
119
+ if new_contents == contents
120
+ message = "[ActualDbSchema] post-checkout git hook already contains the necessary code. Nothing to update."
121
+ puts colorize(message, :gray)
122
+ else
123
+ write_hook_file(new_contents)
124
+ puts colorize("[ActualDbSchema] post-checkout git hook updated successfully at #{hook_path}", :green)
125
+ end
126
+ end
127
+
128
+ def replace_marker_contents(contents)
129
+ contents.gsub(
130
+ /#{Regexp.quote(POST_CHECKOUT_MARKER_START)}.*#{Regexp.quote(POST_CHECKOUT_MARKER_END)}/m,
131
+ hook_code.strip
132
+ )
133
+ end
134
+
135
+ def safe_install?
136
+ puts colorize("[ActualDbSchema] A post-checkout hook already exists at #{hook_path}.", :gray)
137
+ puts "Overwrite the existing hook at #{hook_path}? [y,n] "
138
+
139
+ answer = $stdin.gets.chomp.downcase
140
+ answer.start_with?("y")
141
+ end
142
+
143
+ def install_hook
144
+ contents = File.read(hook_path)
145
+ new_contents = <<~BASH
146
+ #{contents.rstrip}
147
+
148
+ #{hook_code}
149
+ BASH
150
+
151
+ write_hook_file(new_contents)
152
+ print_success
153
+ end
154
+
155
+ def show_manual_install_instructions
156
+ puts colorize("[ActualDbSchema] You can follow these steps to manually install the hook:", :yellow)
157
+ puts <<~MSG
158
+
159
+ 1. Open the existing post-checkout hook at:
160
+ #{hook_path}
161
+
162
+ 2. Insert the following lines into that file (preferably at the end or in a relevant section).
163
+ Make sure you include the #{POST_CHECKOUT_MARKER_START} and #{POST_CHECKOUT_MARKER_END} lines:
164
+
165
+ #{hook_code}
166
+
167
+ 3. Ensure the post-checkout file is executable:
168
+ chmod +x #{hook_path}
169
+
170
+ 4. Done! Now when you switch branches, phantom migrations will be rolled back automatically (if enabled).
171
+
172
+ MSG
173
+ end
174
+
175
+ def write_hook_file(contents)
176
+ File.open(hook_path, "w") { |file| file.write(contents) }
177
+ FileUtils.chmod("+x", hook_path)
178
+ end
179
+
180
+ def print_success
181
+ puts colorize("[ActualDbSchema] post-checkout git hook installed successfully at #{hook_path}", :green)
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActualDbSchema
4
+ # Provides functionality for formatting terminal output with colors
5
+ module OutputFormatter
6
+ UNICODE_COLORS = {
7
+ red: 31,
8
+ green: 32,
9
+ yellow: 33,
10
+ gray: 90
11
+ }.freeze
12
+
13
+ def colorize(text, color)
14
+ code = UNICODE_COLORS.fetch(color, 37)
15
+ "\e[#{code}m#{text}\e[0m"
16
+ end
17
+ end
18
+ end
@@ -4,15 +4,22 @@ module ActualDbSchema
4
4
  module Patches
5
5
  # Add new command to roll back the phantom migrations
6
6
  module MigrationContext
7
+ include ActualDbSchema::OutputFormatter
8
+
7
9
  def rollback_branches(manual_mode: false)
10
+ rolled_back = false
11
+
8
12
  phantom_migrations.reverse_each do |migration|
9
13
  next unless status_up?(migration)
10
14
 
15
+ rolled_back = true
11
16
  show_info_for(migration) if manual_mode
12
17
  migrate(migration) if !manual_mode || user_wants_rollback?
13
18
  rescue StandardError => e
14
- handle_migration_error(e, migration)
19
+ handle_rollback_error(migration, e)
15
20
  end
21
+
22
+ rolled_back
16
23
  end
17
24
 
18
25
  def phantom_migrations
@@ -63,7 +70,7 @@ module ActualDbSchema
63
70
  end
64
71
 
65
72
  def show_info_for(migration)
66
- puts "\n[ActualDbSchema] A phantom migration was found and is about to be rolled back."
73
+ puts colorize("\n[ActualDbSchema] A phantom migration was found and is about to be rolled back.", :gray)
67
74
  puts "Please make a decision from the options below to proceed.\n\n"
68
75
  puts "Branch: #{branch_for(migration.version.to_s)}"
69
76
  puts "Database: #{ActualDbSchema.db_config[:database]}"
@@ -71,16 +78,22 @@ module ActualDbSchema
71
78
  puts File.read(migration.filename)
72
79
  end
73
80
 
74
- def handle_migration_error(error, migration)
75
- raise unless error.message.include?("ActiveRecord::IrreversibleMigration")
81
+ def migrate(migration)
82
+ migration.name = extract_class_name(migration.filename)
76
83
 
77
- ActualDbSchema.failed << migration
78
- end
84
+ message = "[ActualDbSchema] Rolling back phantom migration #{migration.version} #{migration.name} " \
85
+ "(from branch: #{branch_for(migration.version.to_s)})"
86
+ puts colorize(message, :gray)
79
87
 
80
- def migrate(migration)
81
88
  migrator = down_migrator_for(migration)
82
89
  migrator.extend(ActualDbSchema::Patches::Migrator)
83
90
  migrator.migrate
91
+ File.delete(migration.filename)
92
+ end
93
+
94
+ def extract_class_name(filename)
95
+ content = File.read(filename)
96
+ content.match(/^class\s+([A-Za-z0-9_]+)\s+</)[1]
84
97
  end
85
98
 
86
99
  def branch_for(version)
@@ -90,6 +103,21 @@ module ActualDbSchema
90
103
  def metadata
91
104
  @metadata ||= ActualDbSchema::Store.instance.read
92
105
  end
106
+
107
+ def handle_rollback_error(migration, exception)
108
+ error_message = <<~ERROR
109
+ Error encountered during rollback:
110
+
111
+ #{exception.message.gsub(/^An error has occurred, all later migrations canceled:\s*/, "").strip}
112
+ ERROR
113
+
114
+ puts colorize(error_message, :red)
115
+ ActualDbSchema.failed << FailedMigration.new(
116
+ migration: migration,
117
+ exception: exception,
118
+ branch: branch_for(migration.version.to_s)
119
+ )
120
+ end
93
121
  end
94
122
  end
95
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActualDbSchema
4
- VERSION = "0.7.8"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -7,10 +7,13 @@ require_relative "actual_db_schema/git"
7
7
  require_relative "actual_db_schema/store"
8
8
  require_relative "actual_db_schema/version"
9
9
  require_relative "actual_db_schema/migration"
10
+ require_relative "actual_db_schema/failed_migration"
10
11
  require_relative "actual_db_schema/migration_context"
12
+ require_relative "actual_db_schema/output_formatter"
11
13
  require_relative "actual_db_schema/patches/migration_proxy"
12
14
  require_relative "actual_db_schema/patches/migrator"
13
15
  require_relative "actual_db_schema/patches/migration_context"
16
+ require_relative "actual_db_schema/git_hooks"
14
17
 
15
18
  require_relative "actual_db_schema/commands/base"
16
19
  require_relative "actual_db_schema/commands/rollback"
@@ -28,7 +31,8 @@ module ActualDbSchema
28
31
  self.config = {
29
32
  enabled: Rails.env.development?,
30
33
  auto_rollback_disabled: ENV["ACTUAL_DB_SCHEMA_AUTO_ROLLBACK_DISABLED"].present?,
31
- ui_enabled: Rails.env.development? || ENV["ACTUAL_DB_SCHEMA_UI_ENABLED"].present?
34
+ ui_enabled: Rails.env.development? || ENV["ACTUAL_DB_SCHEMA_UI_ENABLED"].present?,
35
+ git_hooks_enabled: ENV["ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"].present?
32
36
  }
33
37
 
34
38
  def self.migrated_folder
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :actual_db_schema do
4
+ desc "Install ActualDbSchema post-checkout git hook that rolls back phantom migrations when switching branches."
5
+ task :install_git_hooks do
6
+ extend ActualDbSchema::OutputFormatter
7
+
8
+ puts "Which Git hook strategy would you like to install? [1, 2, 3]"
9
+ puts " 1) Rollback phantom migrations (db:rollback_branches)"
10
+ puts " 2) Migrate up to latest (db:migrate)"
11
+ puts " 3) No hook installation (skip)"
12
+ answer = $stdin.gets.chomp
13
+
14
+ strategy =
15
+ case answer
16
+ when "1" then :rollback
17
+ when "2" then :migrate
18
+ else
19
+ :none
20
+ end
21
+
22
+ if strategy == :none
23
+ puts colorize("[ActualDbSchema] Skipping git hook installation.", :gray)
24
+ else
25
+ ActualDbSchema::GitHooks.new(strategy: strategy).install_post_checkout_hook
26
+ end
27
+ end
28
+ 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.8
4
+ version: 0.8.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: 2024-08-07 00:00:00.000000000 Z
11
+ date: 2024-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -146,14 +146,18 @@ files:
146
146
  - lib/actual_db_schema/commands/list.rb
147
147
  - lib/actual_db_schema/commands/rollback.rb
148
148
  - lib/actual_db_schema/engine.rb
149
+ - lib/actual_db_schema/failed_migration.rb
149
150
  - lib/actual_db_schema/git.rb
151
+ - lib/actual_db_schema/git_hooks.rb
150
152
  - lib/actual_db_schema/migration.rb
151
153
  - lib/actual_db_schema/migration_context.rb
154
+ - lib/actual_db_schema/output_formatter.rb
152
155
  - lib/actual_db_schema/patches/migration_context.rb
153
156
  - lib/actual_db_schema/patches/migration_proxy.rb
154
157
  - lib/actual_db_schema/patches/migrator.rb
155
158
  - lib/actual_db_schema/store.rb
156
159
  - lib/actual_db_schema/version.rb
160
+ - lib/tasks/actual_db_schema.rake
157
161
  - lib/tasks/db.rake
158
162
  - sig/actual_db_schema.rbs
159
163
  homepage: https://blog.widefix.com/actual-db-schema/
@@ -163,7 +167,16 @@ metadata:
163
167
  homepage_uri: https://blog.widefix.com/actual-db-schema/
164
168
  source_code_uri: https://github.com/widefix/actual_db_schema
165
169
  changelog_uri: https://blog.widefix.com/actual-db-schema//blob/main/CHANGELOG.md
166
- post_install_message:
170
+ post_install_message: |+
171
+ Thank you for installing ActualDbSchema!
172
+
173
+ To enable automatic rollback of phantom migrations when switching branches, follow these steps:
174
+ 1. Set `export ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED=true` in your environment, OR
175
+ add `ActualDbSchema.config[:git_hooks_enabled] = true` to your initializer.
176
+ 2. Run `rake actual_db_schema:install_git_hooks` to install the post-checkout Git hook.
177
+
178
+ For more information, see the README.
179
+
167
180
  rdoc_options: []
168
181
  require_paths:
169
182
  - lib
@@ -183,3 +196,4 @@ signing_key:
183
196
  specification_version: 4
184
197
  summary: Keep your DB and schema.rb consistent in dev branches.
185
198
  test_files: []
199
+ ...