Skip to content

Instantly share code, notes, and snippets.

@skiningham
Last active March 6, 2017 22:07
Show Gist options
  • Save skiningham/fb6f380c75ca5a6c65909958f5f52a31 to your computer and use it in GitHub Desktop.
Save skiningham/fb6f380c75ca5a6c65909958f5f52a31 to your computer and use it in GitHub Desktop.
Reproduction script for schema load error. Empty database called "issue_reproduction_development" is required. Full repo: https://github.com/skiningham/issue_reproduction
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
gem "activerecord", "5.0.2"
gem "pg"
end
require "active_record"
require "active_record/schema_dumper"
require "minitest/autorun"
require "logger"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "postgresql", database: "issue_reproduction_development", encoding: "utf8", pool: 5, timeout: 5000, host: "localhost")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :a_short_model_names do |t|
t.string :title
t.text :body
t.timestamps
end
create_table :my_very_long_example_model_name_because_i_think_schema_load_breaks_sometimes do |t|
t.string :title
t.text :body
t.timestamps
end
end
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
class AShortModelName < ApplicationRecord
end
class MyVeryLongExampleModelNameBecauseIThinkSchemaLoadBreaksSometime < ApplicationRecord
end
class BugTest < Minitest::Test
def test_schema_load
filename = 'example_schema.rb'
File.open(filename, "w:utf-8") do |file|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
end
load(filename)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment