Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Created April 2, 2026 17:06
Show Gist options
  • Select an option

  • Save jasonkarns/848e52fe1252bbbad55bfb0420c13d63 to your computer and use it in GitHub Desktop.

Select an option

Save jasonkarns/848e52fe1252bbbad55bfb0420c13d63 to your computer and use it in GitHub Desktop.
namespace :db do
task disconnect: :environment do
ActiveRecord::Base.clear_all_connections!
end
desc "Run migrations from scratch (destructive!!) to validate the veracity of the versioned schema."
task lint: %w[environment disconnect drop create migrate] do
schema = ActiveRecord::Tasks::DatabaseTasks.schema_dump_path ActiveRecord::Base.connection_db_config
sh(*%w[git diff --exit-code --], schema) do |ok, res|
abort "db schema must match the result of running migrations" unless ok
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment