class ActiveRecord::Migration::PGChangeSchemaTest
Attributes
connection[R]
Public Instance Methods
setup()
click to toggle source
Calls superclass method
# File activerecord/test/cases/adapters/postgresql/change_schema_test.rb, line 10 def setup super @connection = ActiveRecord::Base.connection connection.create_table(:strings) do |t| t.string :somedate end end
teardown()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/change_schema_test.rb, line 18 def teardown connection.drop_table :strings end
test_change_string_to_date()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/change_schema_test.rb, line 22 def test_change_string_to_date connection.change_column :strings, :somedate, :timestamp, using: 'CAST("somedate" AS timestamp)' assert_equal :datetime, connection.columns(:strings).find { |c| c.name == "somedate" }.type end
test_change_type_with_array()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/change_schema_test.rb, line 32 def test_change_type_with_array connection.change_column :strings, :somedate, :timestamp, array: true, cast_as: :timestamp column = connection.columns(:strings).find { |c| c.name == "somedate" } assert_equal :datetime, column.type assert column.array? end
test_change_type_with_symbol()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/change_schema_test.rb, line 27 def test_change_type_with_symbol connection.change_column :strings, :somedate, :timestamp, cast_as: :timestamp assert_equal :datetime, connection.columns(:strings).find { |c| c.name == "somedate" }.type end