Last active
April 26, 2018 16:35
-
-
Save abaldwin88/30be7716414315102a14d56bfb186721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
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" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Activate the gem you are reporting the issue against. | |
gem "rails", github: "rails/rails" | |
gem "pg" | |
end | |
require "active_record" | |
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 :payments, force: true do |t| | |
t.datetime :created_at | |
end | |
end | |
class Payment < ActiveRecord::Base | |
end | |
class ChangeCastIndex < ActiveRecord::Migration[6.0] | |
def change | |
add_index :payments, 'CAST(created_at AS date)' | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_cast | |
ChangeCastIndex.migrate(:up) | |
assert_equal ActiveRecord::Base.connection.indexes(:payments).first.name, 'index_payments_on_CAST_created_at_AS_date' | |
ChangeCastIndex.migrate(:down) | |
assert_equal ActiveRecord::Base.connection.indexes(:payments).empty?, true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment