Merge pull request #7046 from betagouv/strong-migrations

Ajout de strong_migrations (linter automatique des migrations Rails)
This commit is contained in:
Pierre de La Morinerie 2022-03-16 10:52:23 +01:00 committed by GitHub
commit 377e359908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 363 additions and 337 deletions

View file

@ -80,6 +80,7 @@ gem 'sentry-ruby'
gem 'sib-api-v3-sdk'
gem 'skylight'
gem 'spreadsheet_architect'
gem 'strong_migrations' # lint database migrations
gem 'typhoeus'
gem 'warden'
gem 'webpacker'

View file

@ -691,6 +691,8 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
strong_migrations (0.8.0)
activerecord (>= 5.2)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
@ -875,6 +877,7 @@ DEPENDENCIES
spreadsheet_architect
spring
spring-commands-rspec
strong_migrations
timecop
typhoeus
vcr

View file

@ -4,3 +4,6 @@
require File.expand_path('config/application', __dir__)
Rails.application.load_tasks
# Alphabetize schema.rb
task 'db:schema:dump': 'strong_migrations:alphabetize_columns'

View file

@ -0,0 +1,26 @@
# Mark existing migrations as safe
StrongMigrations.start_after = 20220315125851
# 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

File diff suppressed because it is too large Load diff

View file

@ -5,11 +5,7 @@ describe Database::MigrationHelpers do
before(:all) do
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Migration.create_table "test_labels", force: true do |t|
t.string :label
t.integer :user_id
end
ActiveRecord::Migration.create_table "test_labels", force: true do |t|
ActiveRecord::Migration.create_table "test_labels" do |t|
t.string :label
t.integer :user_id
end
@ -103,13 +99,13 @@ describe Database::MigrationHelpers do
before(:all) do
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Migration.create_table "test_physicians", force: true do |t|
ActiveRecord::Migration.create_table "test_physicians" do |t|
t.string :name
end
ActiveRecord::Migration.create_table "test_patients", force: true do |t|
ActiveRecord::Migration.create_table "test_patients" do |t|
t.string :name
end
ActiveRecord::Migration.create_table "test_appointments", id: false, force: true do |t|
ActiveRecord::Migration.create_table "test_appointments", id: false do |t|
t.integer :test_physician_id
t.integer :test_patient_id
t.datetime :datetime