Skip to content

Commit

Permalink
add strong migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
k0va1 committed Aug 18, 2024
1 parent 23be225 commit 001486b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ gem "turbo-rails"
gem "sidekiq"
gem "sidekiq-scheduler"

gem "strong_migrations"

group :development, :test do
gem "bullet", "~> 7.1.3"
gem "debug"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ GEM
stimulus-rails (1.3.0)
railties (>= 6.0.0)
stringio (3.0.9)
strong_migrations (2.0.0)
activerecord (>= 6.1)
tailwindcss-rails (2.0.32-x86_64-linux)
railties (>= 6.0.0)
thor (1.3.0)
Expand Down Expand Up @@ -388,6 +390,7 @@ DEPENDENCIES
sprockets-rails
standard
stimulus-rails
strong_migrations
tailwindcss-rails (~> 2.0)
turbo-rails
web-console
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
require_relative "config/application"

Rails.application.load_tasks
task "db:schema:dump": "strong_migrations:alphabetize_columns"
26 changes: 26 additions & 0 deletions config/initializers/strong_migrations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Mark existing migrations as safe
StrongMigrations.start_after = 20240818191740

# Set timeouts for migrations
# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user
StrongMigrations.lock_timeout = 10.seconds
StrongMigrations.statement_timeout = 1.hour

# Analyze tables after indexes are added
# Outdated statistics can sometimes hurt performance
StrongMigrations.auto_analyze = true

# Set the version of the production database
# so the right checks are run in development
# StrongMigrations.target_version = 10

# Add custom checks
# StrongMigrations.add_check do |method, args|
# if method == :add_index && args[0].to_s == "users"
# stop! "No more indexes on the users table"
# end
# end

# Make some operations safe by default
# See https://github.com/ankane/strong_migrations#safe-by-default
# StrongMigrations.safe_by_default = true

0 comments on commit 001486b

Please sign in to comment.