Skip to content

Commit

Permalink
Handle breaking changes for Rails 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Taucher2003 committed Nov 15, 2024
1 parent 3122206 commit ed25b5c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

module Sagittarius
class Application < Rails::Application
config.load_defaults 7.2
config.load_defaults 8.0

# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
Expand Down
22 changes: 22 additions & 0 deletions config/initializers/rails_code_statistics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

return unless defined?(Rails::Command::StatsCommand)

Rails::CodeStatistics.directories.clear
Rails::CodeStatistics.test_types.clear

%w[Controllers Finders GraphQL GRPC Jobs Mailers Models Policies Services].each do |type|
Rails::CodeStatistics.register_directory(type, "app/#{type.downcase}")
end

%w[Config DB Lib Tooling].each do |type|
Rails::CodeStatistics.register_directory(type, type.downcase)
end

%w[Config Finders GraphQL GRPC Lib Models Policies Requests Services Tooling].each do |type|
Rails::CodeStatistics.register_directory("#{type} specs", "spec/#{type.downcase}", test_directory: true)
end

%w[factories support].each do |type|
Rails::CodeStatistics.register_directory("Spec #{type}", "spec/#{type}", test_directory: true)
end
1 change: 1 addition & 0 deletions lib/sagittarius/database/schema_migrations/migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def touch_all

def load_all
return if version_filenames.empty?
return unless @context.connection.pool.schema_migration.table_exists?

values = version_filenames.map { |vf| "('#{@context.connection.quote_string(vf)}')" }

Expand Down
13 changes: 0 additions & 13 deletions lib/tasks/statistics.rake

This file was deleted.

13 changes: 13 additions & 0 deletions spec/lib/sagittarius/database/schema_migrations/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
let(:filenames) { %w[123 456 789] }

it 'inserts the missing versions into schema_migrations' do
allow(connection).to receive(:quote_string).with('schema_migrations').and_return('schema_migrations')
filenames.each do |filename|
allow(connection).to receive(:quote_string).with(filename).and_return(filename)
end
Expand All @@ -96,6 +97,18 @@
ON CONFLICT DO NOTHING
SQL
end

it 'does nothing if schema_migrations table does not exist' do
allow(connection).to receive(:execute)

schema_migration = connection.pool.schema_migration
allow(connection.pool).to receive(:schema_migration).and_return(schema_migration)
allow(schema_migration).to receive(:table_exists?).and_return(false)

migrations.load_all

expect(connection).not_to have_received(:execute)
end
end
end
end

0 comments on commit ed25b5c

Please sign in to comment.