Code Monkey home page Code Monkey logo

activerecord-cockroachdb-adapter's Introduction

ActiveRecord CockroachDB Adapter

CockroachDB adapter for ActiveRecord 5, 6, and 7. This is a lightweight extension of the PostgreSQL adapter that establishes compatibility with CockroachDB.

Installation

Add this line to your project's Gemfile:

gem 'activerecord-cockroachdb-adapter', '~> 7.0.0'

If you're using Rails 5.2, use the 5.2.x versions of this gem.

If you're using Rails 6.0, use the 6.0.x versions of this gem.

If you're using Rails 7.0, use the 7.0.x versions of this gem.

In database.yml, use the following adapter setting:

development:
  adapter: cockroachdb
  port: 26257
  host: <hostname>
  user: <username>

Configuration

In addition to the standard adapter settings, CockroachDB also supports the following:

  • use_follower_reads_for_type_introspection: Use follower reads on queries to the pg_type catalog when set to true. This helps to speed up initialization by reading historical data, but may not find recently created user-defined types.
  • disable_cockroachdb_telemetry: Determines if a telemetry call is made to the database when the connection pool is initialized. Setting this to true will prevent the call from being made.

Working with Spatial Data

The adapter uses RGeo and RGeo-ActiveRecord to represent geometric and geographic data as Ruby objects and easily interface them with the adapter. The following is a brief introduction to RGeo and tips to help setup your spatial application. More documentation about RGeo can be found in the YARD Docs and wiki.

Installing RGeo

RGeo can be installed with the following command:

gem install rgeo

The best way to use RGeo is with GEOS support. If you have a version of libgeos installed, you can check that it was properly linked with RGeo by running the following commands:

require 'rgeo'

RGeo::Geos.supported?
#=> true

If this is false, you may need to specify the GEOS directory while installing. Here's an example linking it to the CockroachDB GEOS binary.

gem install rgeo -- --with-geos-dir=/path/to/cockroach/lib/

Working with RGeo

RGeo uses factories to create geometry objects and define their properties. Different factories define their own implementations for standard methods. For instance, the RGeo::Geographic.spherical_factory accepts latitudes and longitues as its coordinates and does computations on a spherical surface, while RGeo::Cartesian.factory implements geometry objects on a plane.

The factory (or factories) you choose to use will depend on the requirements of your application and what you need to do with the geometries they produce. For example, if you are working with points or other simple geometries across long distances and need precise results, the spherical factory is a good choice. If you're working with polygons or multipolygons and analyzing complex relationships between them (intersects?, difference, etc.), then using a cartesian factory backed by GEOS is a much better option.

Once you've selected a factory, you need to create objects. RGeo supports geometry creation through standard constructors (point, line_string, polygon, etc.) or by WKT and WKB.

require 'rgeo'
factory = RGeo::Cartesian.factory(srid: 3857)

# Create a line_string from points
pt1 = factory.point(0,0)
pt2 = factory.point(1,1)
pt3 = factory.point(2,2)
line_string = factory.line_string([pt1,pt2,pt3])

p line_string.length
#=> 2.8284271247461903

# check line_string equality
line_string2 = factory.parse_wkt("LINESTRING (0 0, 1 1, 2 2)")
p line_string == line_string2
#=> true

# create polygon and test intersection with line_string
pt4 = factory.point(0,2)
outer_ring = factory.linear_ring([pt1,pt2,pt3,pt4,pt1])
poly = factory.polygon(outer_ring)

p line_string.intersects? poly
#=> true

Creating Spatial Tables

To store spatial data, you must create a column with a spatial type. PostGIS provides a variety of spatial types, including point, linestring, polygon, and different kinds of collections. These types are defined in a standard produced by the Open Geospatial Consortium. You can specify options indicating the coordinate system and number of coordinates for the values you are storing.

The adapter extends ActiveRecord's migration syntax to support these spatial types. The following example creates five spatial columns in a table:

create_table :my_spatial_table do |t|
  t.column :shape1, :geometry
  t.geometry :shape2
  t.line_string :path, srid: 3857
  t.st_point :lonlat, geographic: true
  t.st_point :lonlatheight, geographic: true, has_z: true
end

The first column, "shape1", is created with type "geometry". This is a general "base class" for spatial types; the column declares that it can contain values of any spatial type.

The second column, "shape2", uses a shorthand syntax for the same type as the shape1 column. You can create a column either by invoking column or invoking the name of the type directly.

The third column, "path", has a specific geometric type, line_string. It also specifies an SRID (spatial reference ID) that indicates which coordinate system it expects the data to be in. The column now has a "constraint" on it; it will accept only LineString data, and only data whose SRID is 3857.

The fourth column, "lonlat", has the st_point type, and accepts only Point data. Furthermore, it declares the column as "geographic", which means it accepts longitude/latitude data, and performs calculations such as distances using a spheroidal domain.

The fifth column, "lonlatheight", is a geographic (longitude/latitude) point that also includes a third "z" coordinate that can be used to store height information.

The following are the data types understood by PostGIS and exposed by the adapter:

  • :geometry -- Any geometric type
  • :st_point -- Point data
  • :line_string -- LineString data
  • :st_polygon -- Polygon data
  • :geometry_collection -- Any collection type
  • :multi_point -- A collection of Points
  • :multi_line_string -- A collection of LineStrings
  • :multi_polygon -- A collection of Polygons

Following are the options understood by the adapter:

  • :geographic -- If set to true, create a PostGIS geography column for longitude/latitude data over a spheroidal domain; otherwise create a geometry column in a flat coordinate system. Default is false. Also implies :srid set to 4326.
  • :srid -- Set a SRID constraint for the column. Default is 4326 for a geography column, or 0 for a geometry column. Note that PostGIS currently (as of version 2.0) requires geography columns to have SRID 4326, so this constraint is of limited use for geography columns.
  • :has_z -- Specify that objects in this column include a Z coordinate. Default is false.
  • :has_m -- Specify that objects in this column include an M coordinate. Default is false.

To create a PostGIS spatial index, add using: :gist to your index:

add_index :my_table, :lonlat, using: :gist

# or

change_table :my_table do |t|
  t.index :lonlat, using: :gist
end

Configuring ActiveRecord

ActiveRecord's usefulness stems from the way it automatically configures classes based on the database structure and schema. If a column in the database has an integer type, ActiveRecord automatically casts the data to a Ruby Integer. In the same way, the adapter automatically casts spatial data to a corresponding RGeo data type.

RGeo offers more flexibility in its type system than can be interpreted solely from analyzing the database column. For example, you can configure RGeo objects to exhibit certain behaviors related to their serialization, validation, coordinate system, or computation. These settings are embodied in the RGeo factory associated with the object.

You can configure the adapter to use a particular factory (i.e. a particular combination of settings) for data associated with each type in the database.

Here's an example using a Geos default factory:

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  # By default, use the GEOS implementation for spatial columns.
  config.default = RGeo::Geos.factory_generator

  # But use a geographic implementation for point columns.
  config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

The default spatial factory for geographic columns is RGeo::Geographic.spherical_factory. The default spatial factory for cartesian columns is RGeo::Cartesian.preferred_factory. You do not need to configure the SpatialFactoryStore if these defaults are ok.

More information about configuration options for the SpatialFactoryStore can be found in the rgeo-activerecord docs.

Reading and Writing Spatial Columns

When you access a spatial attribute on your ActiveRecord model, it is given to you as an RGeo geometry object (or nil, for attributes that allow null values). You can then call the RGeo api on the object. For example, consider the MySpatialTable class we worked with above:

record = MySpatialTable.find(1)
point = record.lonlat                  # Returns an RGeo::Feature::Point
p point.x                              # displays the x coordinate
p point.geometry_type.type_name        # displays "Point"

The RGeo factory for the value is determined by how you configured the ActiveRecord class, as described above. In this case, we explicitly set a spherical factory for the :lonlat column:

factory = point.factory                # returns a spherical factory

You can set a spatial attribute by providing an RGeo geometry object, or by providing the WKT string representation of the geometry. If a string is provided, the adapter will attempt to parse it as WKT and set the value accordingly.

record.lonlat = 'POINT(-122 47)'  # sets the value to the given point

If the WKT parsing fails, the value currently will be silently set to nil. In the future, however, this will raise an exception.

record.lonlat = 'POINT(x)'         # sets the value to nil

If you set the value to an RGeo object, the factory needs to match the factory for the attribute. If the factories do not match, the adapter will attempt to cast the value to the correct factory.

p2 = factory.point(-122, 47)       # p2 is a point in a spherical factory
record.lonlat = p2                 # sets the value to the given point
record.shape1 = p2                 # shape1 uses a flat geos factory, so it
                                   # will cast p2 into that coordinate system
                                   # before setting the value
record.save

If you attempt to set the value to the wrong type, such as setting a linestring attribute to a point value, you will get an exception from the database when you attempt to save the record.

record.path = p2      # This will appear to work, but...
record.save           # This will raise an exception from the database

Spatial Queries

You can create simple queries based on representational equality in the same way you would on a scalar column:

record2 = MySpatialTable.where(:lonlat => factory.point(-122, 47)).first

You can also use WKT:

record3 = MySpatialTable.where(:lonlat => 'POINT(-122 47)').first

Note that these queries use representational equality, meaning they return records where the lonlat value matches the given value exactly. A 0.00001 degree difference would not match, nor would a different representation of the same geometry (like a multi_point with a single element). Equality queries aren't generally all that useful in real world applications. Typically, if you want to perform a spatial query, you'll look for, say, all the points within a given area. For those queries, you'll need to use the standard spatial SQL functions provided by PostGIS.

To perform more advanced spatial queries, you can use the extended Arel interface included in the adapter. The functions accept WKT strings or RGeo features.

point = RGeo::Geos.factory(srid: 0).point(1,1)

# Example Building model where geom is a column of polygons.
buildings = Building.arel_table
containing_buiildings = Building.where(buildings[:geom].st_contains(point))

See the rgeo-activerecord YARD Docs for a list of available PostGIS functions.

Validation Issues

If you see an RGeo::Error::InvalidGeometry (LinearRing failed ring test) message while loading data or creating geometries, this means that the geometry you are trying to instantiate is not topologically valid. This is usually due to self-intersections in the geometry. The default behavior of RGeo factories is to raise this error when an invalid geometry is being instansiated, but this can be ignored by setting the uses_lenient_assertions flag to true when creating your factory.

regular_fac = RGeo::Geographic.spherical_factory
modified_fac = RGeo::Geographic.spherical_factory(uses_lenient_assertions: true)

wkt = "POLYGON (0 0, 1 1, 0 1, 1 0, 0 0)" # closed ring with self intersection

regular_fac.parse_wkt(wkt)
#=> RGeo::Error::InvalidGeometry (LinearRing failed ring test)

p modified_fac.parse_wkt(wkt)
#=>  #<RGeo::Geographic::SphericalPolygonImpl>

Be careful when performing calculations on potentially invalid geometries, as the results might be nonsensical. For example, the area returned of an hourglass made of 2 equivalent triangles with a self-intersection in the middle is 0.

Note that when using the spherical_factory, there is a chance that valid geometries will be interpreted as invalid due to floating point issues with small geometries.

Modifying the adapter?

See CONTRIBUTING.md for more details on setting up the environment and making modifications.

activerecord-cockroachdb-adapter's People

Contributors

alimi avatar andyyang890 avatar apantel avatar buonomo avatar cabello avatar carlallen avatar cikey avatar dikshant avatar ecwall avatar fabricioalbarnaz avatar fx-hao avatar jordanlewis avatar keithdoggett avatar lgo avatar marlabrizel avatar marmitoth avatar natelong avatar otan avatar rafiss avatar rail avatar solongordon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activerecord-cockroachdb-adapter's Issues

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/bit_string_test.rb

Failure:
PostgresqlBitStringTest#test_schema_dumping [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bit_string_test.rb:58]:
Expected /t\.bit\s+"a_bit",\s+limit: 8,\s+default: "00000011"$/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"postgresql_bit_strings\", force: :cascade do |t|\n    t.bit \"a_bit\", limit: 8\n    t.bit_varying \"a_bit_varying\", limit: 4\n    t.bit \"another_bit\", limit: 1\n    t.bit_varying \"another_bit_varying\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bit_string_test.rb:56

Failure:
PostgresqlBitStringTest#test_default [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bit_string_test.rb:49]:
Expected: "00000011"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bit_string_test.rb:48

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Update version to follow ActiveRecord versioning

Other 3rd party ActiveRecord adapters like ActiveRecord SQL Server Adapter and Oracle Enhanced release versions that line up with the ActiveRecord version they work against. For example, Oracle Enhanced 6.0.0 works with ActiveRecord 6.0.0. This makes it easy to quickly see what ActiveRecord versions the 3rd party adapters support. We can do the same thing with ActiveRecord CockroachDB Adapter.

To do this, we'd want to do something like

  • create a tag/release for the currently published gem, 0.2.3, at 66a9c65
  • create a branch for development against ActiveRecord 5.2
  • update ActiveRecord CockroachDB Adapter's version to 5.2
  • create a tag/release for ActiveRecord CockroachDB Adapter 5.2
  • publish ActiveRecord CockroachDB Adapter 5.2 to rubygems

We could then follow the same process for development against ActiveRecord 6.0.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/connection_test.rb

Error:
ActiveRecord::PostgresqlConnectionTest#test_reset_with_transaction:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: the configuration setting "geqo" is not supported
HINT:  You have attempted to use a feature that is not yet implemented.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: SET geqo TO off
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:86:in `test_reset_with_transaction'

Error:
ActiveRecord::PostgresqlConnectionTest#test_reset_with_transaction:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  there is no transaction in progress
: ROLLBACK
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:148:in `exec_rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:21:in `rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:180:in `rollback'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:230:in `block in rollback_transaction'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:228:in `rollback_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `rollback_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1014:in `block in teardown_fixtures'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1013:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1013:in `teardown_fixtures'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:866:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:84

Error:
ActiveRecord::PostgresqlConnectionTest#test_statement_key_is_logged:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near "json": syntax error
DETAIL:  source SQL:
EXPLAIN (FORMAT JSON) EXECUTE a1(1)
                ^
HINT:  try \h <SELECTCLAUSE>
: EXPLAIN (FORMAT JSON) EXECUTE a1(1)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:142:in `test_statement_key_is_logged'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:137

Failure:
ActiveRecord::PostgresqlConnectionTest#test_get_and_release_advisory_lock [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:243]:
expected to find an advisory lock with lock_id 5295901941911233559 but there wasn't one

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:230

Error:
ActiveRecord::PostgresqlConnectionTest#test_reset:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: the configuration setting "geqo" is not supported
HINT:  You have attempted to use a feature that is not yet implemented.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: SET geqo TO off
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:71:in `test_reset'

Error:
ActiveRecord::PostgresqlConnectionTest#test_reset:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  there is no transaction in progress
: ROLLBACK
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:148:in `exec_rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:21:in `rollback_db_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:180:in `rollback'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:230:in `block in rollback_transaction'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:228:in `rollback_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `rollback_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1014:in `block in teardown_fixtures'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1013:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:1013:in `teardown_fixtures'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:866:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:69

Error:
ActiveRecord::PostgresqlConnectionTest#test_reconnection_after_actual_disconnection_with_verify:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: pg_terminate_backend()
: select pg_terminate_backend(-1)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:164:in `test_reconnection_after_actual_disconnection_with_verify'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:156

Failure:
ActiveRecord::PostgresqlConnectionTest#test_default_client_min_messages [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:54]:
Expected: "warning"
  Actual: "notice"

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:53

Error:
ActiveRecord::PostgresqlConnectionTest#test_set_session_variable_true:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: the configuration setting "debug_print_plan" is not supported
HINT:  You have attempted to use a feature that is not yet implemented.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: SET SESSION debug_print_plan = TRUE
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:192:in `block in configure_connection'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `each'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `map'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `configure_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:693:in `connect'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:30:in `new'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:30:in `cockroachdb_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:985:in `block in setup_fixtures'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:129:in `finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `block in finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:44:in `finish_with_state'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:29:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:988:in `establish_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_handling.rb:60:in `establish_connection'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:195:in `block in test_set_session_variable_true'
    /Users/alimi/repos/rails/activerecord/test/support/connection_helper.rb:6:in `run_without_connection'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:194:in `test_set_session_variable_true'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:193

Error:
ActiveRecord::PostgresqlConnectionTest#test_set_session_variable_false:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: the configuration setting "debug_print_plan" is not supported
HINT:  You have attempted to use a feature that is not yet implemented.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: SET SESSION debug_print_plan = FALSE
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:192:in `block in configure_connection'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `each'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `map'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:184:in `configure_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:693:in `connect'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:30:in `new'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb_adapter.rb:30:in `cockroachdb_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:985:in `block in setup_fixtures'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:129:in `finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `block in finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/fanout.rb:48:in `finish'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:44:in `finish_with_state'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:29:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:988:in `establish_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_handling.rb:60:in `establish_connection'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:203:in `block in test_set_session_variable_false'
    /Users/alimi/repos/rails/activerecord/test/support/connection_helper.rb:6:in `run_without_connection'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:202:in `test_set_session_variable_false'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:201

Error:
ActiveRecord::PostgresqlConnectionTest#test_table_alias_length_logs_name:
NoMethodError: undefined method `[]' for nil:NilClass
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:118:in `test_table_alias_length_logs_name'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:115

Error:
ActiveRecord::PostgresqlConnectionTest#test_connection_options:
ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR:  unrecognized configuration parameter "geqo"
: show geqo
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:65:in `test_connection_options'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:59

Failure:
ActiveRecord::PostgresqlConnectionTest#test_release_non_existent_advisory_lock [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:258]:
expected release_advisory_lock to return false when there was no lock to release.
Expected: true
  Actual: false

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/connection_test.rb:254

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

ActiveRecord 4 Support

Is there a chance this will work with ActiveRecord 4.x?

If not, is there any plan to add support for this?

Alter table no longer works after updating to beta-20170413

Looks like the latest 20170413 beta broke any migrations that alter a table. Looks like it might be due to this PR cockroachdb/cockroach#14368.

Haven't found a work around yet. Rolling back to the 20170330 version alter table worked.

Error:

PG::InternalError: ERROR:  statement cannot follow a schema change in a transaction
: INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"

Cockroach version:

CockroachDB node starting at 2017-04-14 04:25:24.652071187 +0000 UTC
build:      CCL beta-20170413-dirty @ 2017/04/13 21:06:17 (go1.8.1)
admin:      http://12c3b6ed5083:8080
sql:        postgresql://root@12c3b6ed5083:26257?sslmode=disable
logs:       /data/logs
store[0]:   path=/data
status:     restarted pre-existing node
clusterID:  cc833425-15bf-4781-be38-c9934e24140f
nodeID:     1

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/postgresql_adapter_test.rb

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_default_sequence_name_bad_table [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:94]:
Expected: "zomg_id_seq"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:93

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_exec_insert_with_returning_disabled_and_no_sequence_name_given:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "postgresql_partitioned_table_parent" does not exist
: insert into postgresql_partitioned_table_parent (number) VALUES (1)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:117:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:57:in `test_exec_insert_with_returning_disabled_and_no_sequence_name_given'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:55

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_exec_insert_with_returning_disabled:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "postgresql_partitioned_table_parent" does not exist
: insert into postgresql_partitioned_table_parent (number) VALUES (1)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:117:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:50:in `test_exec_insert_with_returning_disabled'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:48

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_pk_and_sequence_for_with_non_standard_primary_key [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:112]:
Expected: "code"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:109

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_bad_connection [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:19]:
[ActiveRecord::NoDatabaseError] exception expected, not
Class: <ActiveRecord::StatementInvalid>
Message: <"PG::InvalidCatalogName: ERROR:  database \"should_not_exist-cinco-dog-db\" does not exist\n:             SELECT t.oid, t.typname\n            FROM pg_type as t\n            WHERE t.typname IN ('int2', 'int4', 'int8', 'oid', 'float4', 'float8', 'bool')\n">
---Backtrace---
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
/Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
/Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:826:in `add_pg_decoders'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:232:in `initialize'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection'
/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:21:in `block in test_bad_connection'
---------------

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:18

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_exec_insert_default_values_with_returning_disabled_and_no_sequence_name_given:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "postgresql_partitioned_table_parent" does not exist
: insert into postgresql_partitioned_table_parent DEFAULT VALUES
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:117:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:64:in `test_exec_insert_default_values_with_returning_disabled_and_no_sequence_name_given'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:62

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_default_sequence_name [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:86]:
Expected: "public.accounts_id_seq"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:85

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_index_with_opclass:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near "varchar_pattern_ops": syntax error
DETAIL:  source SQL:
CREATE  INDEX  "index_ex_on_data" ON "ex"  ("data" varchar_pattern_ops)
                                                   ^
HINT:  try \h CREATE INDEX
: CREATE  INDEX  "index_ex_on_data" ON "ex"  ("data" varchar_pattern_ops)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/schema_statements.rb:8:in `add_index'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:253:in `block in test_index_with_opclass'
    /Users/alimi/repos/rails/activerecord/test/support/ddl_helper.rb:6:in `with_example_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:384:in `with_example_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:252:in `test_index_with_opclass'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:251

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_partial_index [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:237]:
Expected: "(number > 100)"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:233

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_expression_index:
NoMethodError: undefined method `columns' for nil:NilClass
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:246:in `block in test_expression_index'
    /Users/alimi/repos/rails/activerecord/test/support/ddl_helper.rb:6:in `with_example_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:384:in `with_example_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:242:in `test_expression_index'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:241

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_pk_and_sequence_for [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:104]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:101

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_exec_insert_default_values_quoted_schema_with_returning_disabled_and_no_sequence_name_given:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "public.postgresql_partitioned_table_parent" does not exist
: insert into "public"."postgresql_partitioned_table_parent" DEFAULT VALUES
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:117:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:71:in `test_exec_insert_default_values_quoted_schema_with_returning_disabled_and_no_sequence_name_given'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:69

Failure:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_unparsed_defaults_are_at_least_set_when_saving [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:370]:
Expected "4" to be nil.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:364

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_serial_sequence:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: pg_get_serial_sequence()
: SELECT pg_get_serial_sequence('accounts', 'id')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:98:in `query_value'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:255:in `serial_sequence'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:78:in `test_serial_sequence'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:76

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_pk_and_sequence_for_with_collision_pg_class_oid:
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  user root does not have DELETE privilege on relation pg_depend
: DELETE FROM pg_depend WHERE objid = 'ex_id_seq'::regclass AND refobjid = 'ex'::regclass AND deptype = 'a'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:596:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:157:in `test_pk_and_sequence_for_with_collision_pg_class_oid'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:133

Error:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapterTest#test_reload_type_map_for_newly_defined_types:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  at or near "if": syntax error: unimplemented: this syntax
DETAIL:  source SQL:
DROP TYPE IF EXISTS feeling
          ^
HINT:  You have attempted to use a feature that is not yet implemented.
See: https://github.com/cockroachdb/cockroach/issues/27793
: DROP TYPE IF EXISTS feeling
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:327:in `ensure in test_reload_type_map_for_newly_defined_types'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:328:in `test_reload_type_map_for_newly_defined_types'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb:321

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/columns_test.rb

Error:
ActiveRecord::Migration::ColumnsTest#test_remove_column_with_multi_column_index:
ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR:  column "hat_size" is referenced by existing index "index_test_models_on_hat_style_and_hat_size"
: ALTER TABLE "test_models" DROP COLUMN "hat_size"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:603:in `remove_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/helper.rb:38:in `remove_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:154:in `test_remove_column_with_multi_column_index'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:144

Error:
ActiveRecord::Migration::ColumnsTest#test_change_column:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: type conversion not yet implemented
HINT:  You have attempted to use a feature that is not yet implemented.
See: https://github.com/cockroachdb/cockroach/issues/9851
: ALTER TABLE "test_models" ALTER COLUMN "age" TYPE character varying
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:427:in `change_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/helper.rb:38:in `change_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:197:in `test_change_column'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:189

Failure:
ActiveRecord::Migration::ColumnsTest#test_change_column_default_with_from_and_to [/Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:291]:
Expected: "Tester"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:287

Failure:
ActiveRecord::Migration::ColumnsTest#test_change_column_default [/Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:278]:
Expected: "Tester"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/columns_test.rb:274

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/array_test.rb

All tests fail because the setup is trying to create a table with an hstore column, and hstore is not a supported type in CockroachDB.

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/infinity_test.rb

Failure:
PostgresqlInfinityTest#test_update_all_with_infinity_on_a_datetime_column [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:70]:
--- expected
+++ actual
@@ -1 +1 @@
-Infinity
+-292277022365-05-08 08:17:07 UTC


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:66

Failure:
PostgresqlInfinityTest#test_update_all_with_infinity_on_a_float_column [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:43]:
Expected: Infinity
  Actual: 0.0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:39

Failure:
PostgresqlInfinityTest#test_type_casting_infinity_on_a_datetime_column [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:49]:
--- expected
+++ actual
@@ -1 +1 @@
-Infinity
+-292277022365-05-08 08:17:07 UTC


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:46

Failure:
PostgresqlInfinityTest#test_assigning_'infinity'_on_a_datetime_column_with_TZ_aware_attributes [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:78]:
--- expected
+++ actual
@@ -1 +1 @@
-Infinity
+-292277022365-05-08 08:17:07 UTC


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:73

Failure:
PostgresqlInfinityTest#test_type_casting_infinity_on_a_float_column [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:27]:
Expected: Infinity
  Actual: 0.0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/infinity_test.rb:24

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/compatibility_test.rb

Failure:
LegacyPrimaryKeyTest::V5_0#test_add_column_with_legacy_primary_key_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:260]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:248

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_in_create_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:228]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:217

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_should_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:182]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:171

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_integer_primary_key_should_not_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:214]:
Expected /create_table "legacy_primary_keys", id: :integer, default: nil/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"legacy_primary_keys\", id: :bigint, default: nil, force: :cascade do |t|\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:197

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_join_table_foreign_keys_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:274]:
Expected /integer "apple_id", null: false/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"apples_bananas\", id: false, force: :cascade do |t|\n    t.bigint \"apple_id\", null: false\n    t.bigint \"banana_id\", null: false\n    t.bigserial \"rowid\", null: false\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:263

Failure:
LegacyPrimaryKeyTest::V5_0#test_legacy_primary_key_in_change_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:245]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:231

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_should_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:182]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:171

Failure:
LegacyPrimaryKeyTest::V4_2#test_add_column_with_legacy_primary_key_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:260]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:248

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_join_table_foreign_keys_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:274]:
Expected /integer "apple_id", null: false/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"apples_bananas\", id: false, force: :cascade do |t|\n    t.bigint \"apple_id\", null: false\n    t.bigint \"banana_id\", null: false\n    t.bigserial \"rowid\", null: false\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:263

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_in_change_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:245]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:231

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_primary_key_in_create_table_should_be_integer [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:228]:
Expected: "id"
  Actual: nil

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:217

Failure:
LegacyPrimaryKeyTest::V4_2#test_legacy_integer_primary_key_should_not_be_auto_incremented [/Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:214]:
Expected /create_table "legacy_primary_keys", id: :integer, default: nil/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"legacy_primary_keys\", id: :bigint, default: nil, force: :cascade do |t|\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:197

Error:
ActiveRecord::Migration::CompatibilityTest#test_legacy_change_column_with_null_executes_update:
StandardError: An error has occurred, all later migrations canceled:

PG::CheckViolation: ERROR:  validation of NOT NULL constraint failed: validation of CHECK "foo IS NOT NULL" failed on row: id=547491657331539969, foo=NULL, bar=NULL
: ALTER TABLE "testings" ALTER COLUMN "foo" TYPE character varying(10), ALTER COLUMN "foo" SET DEFAULT 'foobar', ALTER COLUMN "foo" SET NOT NULL
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:427:in `change_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration/compatibility.rb:26:in `change_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:137:in `migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1345:in `ddl_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1262:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1262:in `migrate_without_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1210:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1363:in `with_advisory_lock'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:1210:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:142:in `test_legacy_change_column_with_null_executes_update'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/compatibility_test.rb:134

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Create ActiveRecord 4 variant of adapter

This adapter only supports ActiveRecord 5. There are lots of apps that haven't upgraded to ActiveRecord 5 yet and may not want to, so we should create a variant of the adapter that supports ActiveRecord 4.

There are some minor internal API differences between AR 4 and 5 which is why the current adapter doesn't work.

Consider supporting latest pg version

Hi ๐Ÿ‘‹

The gem currently requires pg 0.21.0 from June 12, 2017 (209 KB)
While 1.1.3 is the latest version of the pg gem released in September 07, 2018.

gem Changelog

We've been using pg 1.x for a while in production, it would be helpful to be able to use cockroachdb with the latest version of pg.

Add documentation, release process, and improve testing

Lumping this all together as these are all improvements that just come with better support for the adapter.

  • Create a proper release process
    • Releasing to rubygems. (Look into using TravisCI to automatically publish tags)
    • Changelog
    • Tagging
    • Make sure to support Activerecord 4.x (our 1.x) and 5.x (our 2.x) ๐Ÿ‘. This could either be using two different branches, or supporting them from the same branch (sort of like Py2 vs Py3 support).
  • Add documentation (and changelog)
  • Improve testing
    • Possibly pull in existing ActiveRecord PostgreSQL tests. Again, we'll have to do this separately for the different ActiveRecord versions likely.
  • Add rake tasks to manage the database
  • Add custom CockroachDB capabilities
    • Don't use PostgreSQL types, but use cockroach types. We'll then alias PostgreSQL ones to their respective CockroachDB one

unknown variable: "timezone"

PG::InternalError: ERROR: unknown variable: "timezone" (ActiveRecord::StatementInvalid) : SET SESSION timezone TO 'UTC'

This seems to be caused by the inherited-from pg code trying to set a variable named timezone on connection start, but cockroach calls this variable time zone

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/bytea_test.rb

Error:
PostgresqlByteaTest#test_via_to_sql_with_complicating_connection:
ActiveRecord::StatementInvalid: PG::InvalidParameterValue: ERROR:  invalid value for parameter "standard_conforming_strings": "off"
DETAIL:  this parameter is currently recognized only for compatibility and has no effect in CockroachDB.
HINT:  Available values: on
: SET standard_conforming_strings = off
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bytea_test.rb:93:in `block in test_via_to_sql_with_complicating_connection'

Error:
PostgresqlByteaTest#test_via_to_sql_with_complicating_connection:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "bytea_data_type"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/bytea_test.rb:28:in `block in <class:PostgresqlByteaTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/schema_dumper_test.rb

Failure:
SchemaDumperTest#test_schema_dump_interval_type [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:307]:
Expected /t\.interval\s+"scaled_time_interval",\s+precision: 6$/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"postgresql_times\", force: :cascade do |t|\n    t.interval \"time_interval\"\n    t.interval \"scaled_time_interval\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:304

Failure:
SchemaDumperTest#test_schema_dump_includes_bigint_default [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:286]:
Expected /t\.bigint\s+"bigint_default",\s+default: 0/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"defaults\", force: :cascade do |t|\n    t.date \"modified_date\", default: -> { \"current_date()\" }\n    t.date \"modified_date_function\", default: -> { \"now()\" }\n    t.date \"fixed_date\", default: \"2004-01-01\"\n    t.datetime \"modified_time\", default: -> { \"current_timestamp()\" }\n    t.datetime \"modified_time_function\", default: -> { \"now()\" }\n    t.datetime \"fixed_time\", default: \"2004-01-01 05:00:00\"\n    t.string \"char1\", limit: 1, default: \"Y\"\n    t.string \"char2\", limit: 50, default: \"a varchar field\"\n    t.text \"char3\", default: \"a text field\"\n    t.bigint \"bigint_default\"\n    t.text \"multiline_default\", default: \"--- []\\n\\n\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:284

Failure:
SchemaDumperTest#test_schema_dump_allows_array_of_decimal_defaults [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:296]:
Expected /t\.decimal\s+"decimal_array_default",\s+default: \["1.23", "3.45"\],\s+array: true/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"bigint_array\", force: :cascade do |t|\n    t.bigint \"big_int_data_points\", array: true\n    t.decimal \"decimal_array_default\", array: true\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:294

Failure:
SchemaDumperTest#test_schema_dump_keeps_large_precision_integer_columns_as_decimal [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:352]:
Expected /t\.decimal\s+"atoms_in_universe",\s+precision: 55/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"CamelCase\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"accounts\", force: :cascade do |t|\n    t.bigint \"firm_id\"\n    t.string \"firm_name\"\n    t.bigint \"credit_limit\"\n  end\n\n  create_table \"admin_accounts\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"admin_users\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"settings\", limit: 1024\n    t.string \"preferences\", limit: 1024, default: \"\"\n    t.string \"json_data\", limit: 1024\n    t.string \"json_data_empty\", limit: 1024, default: \"\"\n    t.text \"params\"\n    t.bigint \"account_id\"\n    t.index [\"account_id\"], name: \"index_admin_users_on_account_id\"\n  end\n\n  create_table \"aircraft\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"wheels_count\", default: 0, null: false\n    t.datetime \"wheels_owned_at\"\n  end\n\n  create_table \"articles\", force: :cascade do |t|\n  end\n\n  create_table \"articles_magazines\", force: :cascade do |t|\n    t.bigint \"article_id\"\n    t.bigint \"magazine_id\"\n    t.index [\"article_id\"], name: \"index_articles_magazines_on_article_id\"\n    t.index [\"magazine_id\"], name: \"index_articles_magazines_on_magazine_id\"\n  end\n\n  create_table \"articles_tags\", force: :cascade do |t|\n    t.bigint \"article_id\"\n    t.bigint \"tag_id\"\n    t.index [\"article_id\"], name: \"index_articles_tags_on_article_id\"\n    t.index [\"tag_id\"], name: \"index_articles_tags_on_tag_id\"\n  end\n\n  create_table \"audit_logs\", force: :cascade do |t|\n    t.string \"message\", null: false\n    t.bigint \"developer_id\", null: false\n    t.bigint \"unvalidated_developer_id\"\n  end\n\n  create_table \"author_addresses\", force: :cascade do |t|\n  end\n\n  create_table \"author_favorites\", force: :cascade do |t|\n    t.bigint \"author_id\"\n    t.bigint \"favorite_author_id\"\n  end\n\n  create_table \"authors\", force: :cascade do |t|\n    t.string \"name\", null: false\n    t.bigint \"author_address_id\"\n    t.bigint \"author_address_extra_id\"\n    t.string \"organization_id\"\n    t.string \"owned_essay_id\"\n    t.index [\"author_address_extra_id\"], name: \"index_authors_on_author_address_extra_id\"\n    t.index [\"author_address_id\"], name: \"index_authors_on_author_address_id\"\n  end\n\n  create_table \"auto_id_tests\", primary_key: \"auto_id\", force: :cascade do |t|\n    t.bigint \"value\"\n  end\n\n  create_table \"bigint_array\", force: :cascade do |t|\n    t.bigint \"big_int_data_points\", array: true\n    t.decimal \"decimal_array_default\", array: true\n  end\n\n  create_table \"binaries\", force: :cascade do |t|\n    t.string \"name\"\n    t.binary \"data\"\n    t.binary \"short_data\"\n  end\n\n  create_table \"birds\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"color\"\n    t.bigint \"pirate_id\"\n  end\n\n  create_table \"books\", force: :cascade do |t|\n    t.bigint \"author_id\"\n    t.string \"format\"\n    t.string \"name\"\n    t.bigint \"status\", default: 0\n    t.bigint \"read_status\", default: 0\n    t.bigint \"nullable_status\"\n    t.bigint \"language\", default: 0\n    t.bigint \"author_visibility\", default: 0\n    t.bigint \"illustrator_visibility\", default: 0\n    t.bigint \"font_size\", default: 0\n    t.bigint \"difficulty\", default: 0\n    t.string \"cover\", default: \"hard\"\n    t.index [\"author_id\"], name: \"index_books_on_author_id\"\n  end\n\n  create_table \"booleans\", force: :cascade do |t|\n    t.boolean \"value\"\n    t.boolean \"has_fun\", default: false, null: false\n  end\n\n  create_table \"bulbs\", primary_key: \"ID\", force: :cascade do |t|\n    t.bigint \"car_id\"\n    t.string \"name\"\n    t.boolean \"frickinawesome\", default: false\n    t.string \"color\"\n  end\n\n  create_table \"cake_designers\", force: :cascade do |t|\n  end\n\n  create_table \"carriers\", force: :cascade do |t|\n  end\n\n  create_table \"cars\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"engines_count\"\n    t.bigint \"wheels_count\", default: 0, null: false\n    t.datetime \"wheels_owned_at\"\n    t.bigint \"lock_version\", default: 0, null: false\n    t.datetime \"created_at\", null: false\n    t.datetime \"updated_at\", null: false\n  end\n\n  create_table \"categories\", force: :cascade do |t|\n    t.string \"name\", null: false\n    t.string \"type\"\n    t.bigint \"categorizations_count\"\n  end\n\n  create_table \"categories_posts\", id: false, force: :cascade do |t|\n    t.bigint \"category_id\", null: false\n    t.bigint \"post_id\", null: false\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"categorizations\", force: :cascade do |t|\n    t.bigint \"category_id\"\n    t.string \"named_category_name\"\n    t.bigint \"post_id\"\n    t.bigint \"author_id\"\n    t.boolean \"special\"\n  end\n\n  create_table \"chefs\", force: :cascade do |t|\n    t.bigint \"employable_id\"\n    t.string \"employable_type\"\n    t.bigint \"department_id\"\n    t.string \"employable_list_type\"\n    t.bigint \"employable_list_id\"\n  end\n\n  create_table \"circles\", force: :cascade do |t|\n  end\n\n  create_table \"citations\", force: :cascade do |t|\n    t.bigint \"book1_id\"\n    t.bigint \"book2_id\"\n    t.bigint \"citation_id\"\n    t.index [\"book1_id\"], name: \"index_citations_on_book1_id\"\n    t.index [\"book2_id\"], name: \"index_citations_on_book2_id\"\n    t.index [\"citation_id\"], name: \"index_citations_on_citation_id\"\n  end\n\n  create_table \"clubs\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"category_id\"\n  end\n\n  create_table \"cold_jokes\", force: :cascade do |t|\n    t.string \"cold_name\"\n  end\n\n  create_table \"collections\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"colnametests\", force: :cascade do |t|\n    t.bigint \"references\", null: false\n  end\n\n  create_table \"columns\", force: :cascade do |t|\n    t.bigint \"record_id\"\n    t.index [\"record_id\"], name: \"index_columns_on_record_id\"\n  end\n\n  create_table \"comments\", force: :cascade do |t|\n    t.bigint \"post_id\", null: false\n    t.text \"body\", null: false\n    t.string \"type\"\n    t.bigint \"tags_count\", default: 0\n    t.bigint \"children_count\", default: 0\n    t.bigint \"parent_id\"\n    t.string \"author_type\"\n    t.bigint \"author_id\"\n    t.string \"resource_id\"\n    t.string \"resource_type\"\n    t.bigint \"developer_id\"\n    t.datetime \"updated_at\"\n    t.datetime \"deleted_at\"\n    t.bigint \"comments\"\n    t.index [\"author_type\", \"author_id\"], name: \"index_comments_on_author_type_and_author_id\"\n  end\n\n  create_table \"companies\", id: :bigint, default: -> { \"nextval('companies_nonstd_seq'::STRING)\" }, force: :cascade do |t|\n    t.string \"type\"\n    t.bigint \"firm_id\"\n    t.string \"firm_name\"\n    t.string \"name\"\n    t.bigint \"client_of\"\n    t.bigint \"rating\", default: 1\n    t.bigint \"account_id\"\n    t.string \"description\", default: \"\"\n    t.index [\"firm_id\", \"type\", \"rating\"], name: \"company_index\", order: { rating: :desc }\n    t.index [\"firm_id\", \"type\"], name: \"company_partial_index\"\n    t.index [\"name\", \"description\"], name: \"index_companies_on_name_and_description\"\n    t.index [\"name\", \"rating\"], name: \"index_companies_on_name_and_rating\", order: :desc\n    t.index [\"name\"], name: \"company_name_index\"\n  end\n\n  create_table \"computers\", force: :cascade do |t|\n    t.string \"system\"\n    t.bigint \"developer\", null: false\n    t.bigint \"extendedWarranty\", null: false\n  end\n\n  create_table \"computers_developers\", id: false, force: :cascade do |t|\n    t.bigint \"computer_id\"\n    t.bigint \"developer_id\"\n    t.bigserial \"rowid\", null: false\n    t.index [\"computer_id\"], name: \"index_computers_developers_on_computer_id\"\n    t.index [\"developer_id\"], name: \"index_computers_developers_on_developer_id\"\n  end\n\n  create_table \"content\", force: :cascade do |t|\n    t.string \"title\"\n  end\n\n  create_table \"content_positions\", force: :cascade do |t|\n    t.bigint \"content_id\"\n  end\n\n  create_table \"contracts\", force: :cascade do |t|\n    t.bigint \"developer_id\"\n    t.bigint \"company_id\"\n    t.string \"metadata\"\n    t.bigint \"count\"\n  end\n\n  create_table \"countries\", id: false, force: :cascade do |t|\n    t.string \"country_id\"\n    t.string \"name\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"countries_treaties\", primary_key: [\"country_id\", \"treaty_id\"], force: :cascade do |t|\n    t.string \"country_id\", null: false\n    t.string \"treaty_id\", null: false\n  end\n\n  create_table \"customer_carriers\", force: :cascade do |t|\n    t.bigint \"customer_id\"\n    t.bigint \"carrier_id\"\n    t.index [\"carrier_id\"], name: \"index_customer_carriers_on_carrier_id\"\n    t.index [\"customer_id\"], name: \"index_customer_carriers_on_customer_id\"\n  end\n\n  create_table \"customers\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"balance\", default: 0\n    t.string \"address_street\"\n    t.string \"address_city\"\n    t.string \"address_country\"\n    t.string \"gps_location\"\n  end\n\n  create_table \"dashboards\", id: false, force: :cascade do |t|\n    t.string \"dashboard_id\"\n    t.string \"name\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"defaults\", force: :cascade do |t|\n    t.date \"modified_date\", default: -> { \"current_date()\" }\n    t.date \"modified_date_function\", default: -> { \"now()\" }\n    t.date \"fixed_date\", default: \"2004-01-01\"\n    t.datetime \"modified_time\", default: -> { \"current_timestamp()\" }\n    t.datetime \"modified_time_function\", default: -> { \"now()\" }\n    t.datetime \"fixed_time\", default: \"2004-01-01 05:00:00\"\n    t.string \"char1\", limit: 1, default: \"Y\"\n    t.string \"char2\", limit: 50, default: \"a varchar field\"\n    t.text \"char3\", default: \"a text field\"\n    t.bigint \"bigint_default\"\n    t.text \"multiline_default\", default: \"--- []\\n\\n\"\n  end\n\n  create_table \"departments\", force: :cascade do |t|\n    t.bigint \"hotel_id\"\n  end\n\n  create_table \"developers\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"first_name\"\n    t.bigint \"salary\", default: 70000\n    t.bigint \"firm_id\"\n    t.bigint \"mentor_id\"\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n    t.datetime \"created_on\"\n    t.datetime \"updated_on\"\n  end\n\n  create_table \"developers_projects\", id: false, force: :cascade do |t|\n    t.bigint \"developer_id\", null: false\n    t.bigint \"project_id\", null: false\n    t.date \"joined_on\"\n    t.bigint \"access_level\", default: 1\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"dog_lovers\", force: :cascade do |t|\n    t.bigint \"trained_dogs_count\", default: 0\n    t.bigint \"bred_dogs_count\", default: 0\n    t.bigint \"dogs_count\", default: 0\n  end\n\n  create_table \"dogs\", force: :cascade do |t|\n    t.bigint \"trainer_id\"\n    t.bigint \"breeder_id\"\n    t.bigint \"dog_lover_id\"\n    t.string \"alias\"\n  end\n\n  create_table \"doubloons\", force: :cascade do |t|\n    t.bigint \"pirate_id\"\n    t.bigint \"weight\"\n  end\n\n  create_table \"drink_designers\", force: :cascade do |t|\n  end\n\n  create_table \"edges\", id: false, force: :cascade do |t|\n    t.bigint \"source_id\", null: false\n    t.bigint \"sink_id\", null: false\n    t.bigserial \"rowid\", null: false\n    t.index [\"source_id\", \"sink_id\"], name: \"unique_edge_index\", unique: true\n  end\n\n  create_table \"electrons\", force: :cascade do |t|\n    t.bigint \"molecule_id\"\n    t.string \"name\"\n  end\n\n  create_table \"engines\", force: :cascade do |t|\n    t.bigint \"car_id\"\n  end\n\n  create_table \"entrants\", force: :cascade do |t|\n    t.string \"name\", null: false\n    t.bigint \"course_id\", null: false\n  end\n\n  create_table \"essays\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"writer_id\"\n    t.string \"writer_type\"\n    t.string \"category_id\"\n    t.string \"author_id\"\n  end\n\n  create_table \"events\", force: :cascade do |t|\n    t.string \"title\", limit: 5\n  end\n\n  create_table \"eyes\", force: :cascade do |t|\n  end\n\n  create_table \"faces\", force: :cascade do |t|\n    t.string \"description\"\n    t.bigint \"man_id\"\n    t.bigint \"polymorphic_man_id\"\n    t.string \"polymorphic_man_type\"\n    t.bigint \"poly_man_without_inverse_id\"\n    t.string \"poly_man_without_inverse_type\"\n    t.bigint \"horrible_polymorphic_man_id\"\n    t.string \"horrible_polymorphic_man_type\"\n    t.string \"human_type\"\n    t.bigint \"human_id\"\n  end\n\n  create_table \"families\", force: :cascade do |t|\n  end\n\n  create_table \"family_trees\", force: :cascade do |t|\n    t.bigint \"family_id\"\n    t.bigint \"member_id\"\n    t.string \"token\"\n    t.index [\"family_id\"], name: \"index_family_trees_on_family_id\"\n    t.index [\"member_id\"], name: \"index_family_trees_on_member_id\"\n  end\n\n  create_table \"fk_test_has_fk\", force: :cascade do |t|\n    t.bigint \"fk_id\", null: false\n    t.index [\"fk_id\"], name: \"fk_test_has_fk_auto_index_fk_name\"\n    t.index [\"fk_id\"], name: \"index_fk_test_has_fk_on_fk_id\"\n  end\n\n  create_table \"fk_test_has_pk\", primary_key: \"pk_id\", force: :cascade do |t|\n  end\n\n  create_table \"friendships\", force: :cascade do |t|\n    t.bigint \"friend_id\"\n    t.bigint \"follower_id\"\n  end\n\n  create_table \"frogs\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"funny_jokes\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"goofy_string_id\", id: false, force: :cascade do |t|\n    t.string \"id\", null: false\n    t.string \"info\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"guids\", force: :cascade do |t|\n    t.string \"key\"\n  end\n\n  create_table \"guitars\", force: :cascade do |t|\n    t.string \"color\"\n  end\n\n  create_table \"having\", force: :cascade do |t|\n    t.string \"where\"\n  end\n\n  create_table \"hotels\", force: :cascade do |t|\n  end\n\n  create_table \"images\", force: :cascade do |t|\n    t.bigint \"imageable_identifier\"\n    t.string \"imageable_class\"\n  end\n\n  create_table \"inept_wizards\", force: :cascade do |t|\n    t.string \"name\", null: false\n    t.string \"city\", null: false\n    t.string \"type\"\n  end\n\n  create_table \"integer_limits\", force: :cascade do |t|\n    t.bigint \"c_int_without_limit\"\n    t.integer \"c_int_1\", limit: 2\n    t.integer \"c_int_2\", limit: 2\n    t.bigint \"c_int_3\"\n    t.bigint \"c_int_4\"\n    t.bigint \"c_int_5\"\n    t.bigint \"c_int_6\"\n    t.bigint \"c_int_7\"\n    t.bigint \"c_int_8\"\n  end\n\n  create_table \"interests\", force: :cascade do |t|\n    t.string \"topic\"\n    t.bigint \"man_id\"\n    t.bigint \"polymorphic_man_id\"\n    t.string \"polymorphic_man_type\"\n    t.bigint \"zine_id\"\n  end\n\n  create_table \"invoices\", force: :cascade do |t|\n    t.bigint \"balance\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"iris\", force: :cascade do |t|\n    t.bigint \"eye_id\"\n    t.string \"color\"\n    t.index [\"eye_id\"], name: \"index_iris_on_eye_id\"\n  end\n\n  create_table \"items\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"jobs\", force: :cascade do |t|\n    t.bigint \"ideal_reference_id\"\n  end\n\n  create_table \"jobs_pool\", id: false, force: :cascade do |t|\n    t.bigint \"job_id\", null: false\n    t.bigint \"user_id\", null: false\n    t.bigserial \"rowid\", null: false\n    t.index [\"job_id\"], name: \"index_jobs_pool_on_job_id\"\n    t.index [\"user_id\"], name: \"index_jobs_pool_on_user_id\"\n  end\n\n  create_table \"keyboards\", primary_key: \"key_number\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"kitchens\", force: :cascade do |t|\n  end\n\n  create_table \"legacy_things\", force: :cascade do |t|\n    t.bigint \"tps_report_number\"\n    t.bigint \"version\", default: 0, null: false\n  end\n\n  create_table \"lessons\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"lessons_students\", id: false, force: :cascade do |t|\n    t.bigint \"lesson_id\"\n    t.bigint \"student_id\"\n    t.bigserial \"rowid\", null: false\n    t.index [\"lesson_id\"], name: \"index_lessons_students_on_lesson_id\"\n    t.index [\"student_id\"], name: \"index_lessons_students_on_student_id\"\n  end\n\n  create_table \"limitless_fields\", force: :cascade do |t|\n    t.binary \"binary\"\n    t.text \"text\"\n  end\n\n  create_table \"line_items\", force: :cascade do |t|\n    t.bigint \"invoice_id\"\n    t.bigint \"amount\"\n  end\n\n  create_table \"lint_models\", force: :cascade do |t|\n  end\n\n  create_table \"lions\", force: :cascade do |t|\n    t.bigint \"gender\"\n    t.boolean \"is_vegetarian\", default: false\n  end\n\n  create_table \"liquid\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"lock_without_defaults\", force: :cascade do |t|\n    t.string \"title\"\n    t.bigint \"lock_version\"\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"lock_without_defaults_cust\", force: :cascade do |t|\n    t.string \"title\"\n    t.bigint \"custom_lock_version\"\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"magazines\", force: :cascade do |t|\n  end\n\n  create_table \"mateys\", id: false, force: :cascade do |t|\n    t.bigint \"pirate_id\"\n    t.bigint \"target_id\"\n    t.bigint \"weight\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"member_details\", force: :cascade do |t|\n    t.bigint \"member_id\"\n    t.bigint \"organization_id\"\n    t.string \"extra_data\"\n  end\n\n  create_table \"member_friends\", id: false, force: :cascade do |t|\n    t.bigint \"member_id\"\n    t.bigint \"friend_id\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"member_types\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"members\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"member_type_id\"\n    t.string \"admittable_type\"\n    t.bigint \"admittable_id\"\n  end\n\n  create_table \"memberships\", force: :cascade do |t|\n    t.datetime \"joined_on\"\n    t.bigint \"club_id\"\n    t.bigint \"member_id\"\n    t.boolean \"favourite\", default: false\n    t.bigint \"type\"\n  end\n\n  create_table \"men\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"mentors\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"mice\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"minimalistics\", force: :cascade do |t|\n  end\n\n  create_table \"minivans\", id: false, force: :cascade do |t|\n    t.string \"minivan_id\"\n    t.string \"name\"\n    t.string \"speedometer_id\"\n    t.string \"color\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"mixed_case_monkeys\", primary_key: \"monkeyID\", force: :cascade do |t|\n    t.bigint \"fleaCount\"\n  end\n\n  create_table \"mixins\", force: :cascade do |t|\n    t.bigint \"parent_id\"\n    t.bigint \"pos\"\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n    t.bigint \"lft\"\n    t.bigint \"rgt\"\n    t.bigint \"root_id\"\n    t.string \"type\"\n  end\n\n  create_table \"molecules\", force: :cascade do |t|\n    t.bigint \"liquid_id\"\n    t.string \"name\"\n  end\n\n  create_table \"movies\", primary_key: \"movieid\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"nodes\", force: :cascade do |t|\n    t.bigint \"tree_id\"\n    t.bigint \"parent_id\"\n    t.string \"name\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"non_poly_ones\", force: :cascade do |t|\n  end\n\n  create_table \"non_poly_twos\", force: :cascade do |t|\n  end\n\n  create_table \"non_primary_keys\", id: false, force: :cascade do |t|\n    t.bigint \"id\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"notifications\", force: :cascade do |t|\n    t.string \"message\"\n  end\n\n  create_table \"numeric_data\", force: :cascade do |t|\n    t.decimal \"bank_balance\", precision: 10, scale: 2\n    t.decimal \"big_bank_balance\", precision: 15, scale: 2\n    t.decimal \"world_population\"\n    t.decimal \"my_house_population\"\n    t.decimal \"decimal_number_with_default\", precision: 3, scale: 2, default: \"2.78\"\n    t.float \"temperature\"\n    t.decimal \"atoms_in_universe\"\n  end\n\n  create_table \"old_cars\", force: :cascade do |t|\n  end\n\n  create_table \"orders\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"billing_customer_id\"\n    t.bigint \"shipping_customer_id\"\n  end\n\n  create_table \"organizations\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"overloaded_types\", force: :cascade do |t|\n    t.float \"overloaded_float\", default: 500.0\n    t.float \"unoverloaded_float\"\n    t.string \"overloaded_string_with_limit\", limit: 255\n    t.string \"string_with_default\", default: \"the original default\"\n  end\n\n  create_table \"owners\", primary_key: \"owner_id\", force: :cascade do |t|\n    t.string \"name\"\n    t.datetime \"updated_at\"\n    t.datetime \"happy_at\"\n    t.string \"essay_id\"\n  end\n\n  create_table \"paint_colors\", force: :cascade do |t|\n    t.bigint \"non_poly_one_id\"\n  end\n\n  create_table \"paint_textures\", force: :cascade do |t|\n    t.bigint \"non_poly_two_id\"\n  end\n\n  create_table \"parrots\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"color\"\n    t.string \"parrot_sti_class\"\n    t.bigint \"killer_id\"\n    t.bigint \"updated_count\", default: 0\n    t.bigint \"integer\", default: 0\n    t.datetime \"created_at\"\n    t.datetime \"created_on\"\n    t.datetime \"updated_at\"\n    t.datetime \"updated_on\"\n  end\n\n  create_table \"parrots_pirates\", id: false, force: :cascade do |t|\n    t.bigint \"parrot_id\"\n    t.bigint \"pirate_id\"\n    t.bigserial \"rowid\", null: false\n    t.index [\"parrot_id\"], name: \"index_parrots_pirates_on_parrot_id\"\n    t.index [\"parrot_id\"], name: \"parrots_pirates_auto_index_fk_rails_65e99344dc\"\n    t.index [\"pirate_id\"], name: \"index_parrots_pirates_on_pirate_id\"\n    t.index [\"pirate_id\"], name: \"parrots_pirates_auto_index_fk_rails_8c00c26daf\"\n  end\n\n  create_table \"parrots_treasures\", id: false, force: :cascade do |t|\n    t.bigint \"parrot_id\"\n    t.bigint \"treasure_id\"\n    t.bigserial \"rowid\", null: false\n    t.index [\"parrot_id\"], name: \"index_parrots_treasures_on_parrot_id\"\n    t.index [\"parrot_id\"], name: \"parrots_treasures_auto_index_fk_rails_2a549fd937\"\n    t.index [\"treasure_id\"], name: \"index_parrots_treasures_on_treasure_id\"\n    t.index [\"treasure_id\"], name: \"parrots_treasures_auto_index_fk_rails_df7e5cc9cf\"\n  end\n\n  create_table \"people\", force: :cascade do |t|\n    t.string \"first_name\", null: false\n    t.bigint \"primary_contact_id\"\n    t.string \"gender\", limit: 1\n    t.bigint \"number1_fan_id\"\n    t.bigint \"lock_version\", default: 0, null: false\n    t.string \"comments\"\n    t.bigint \"followers_count\", default: 0\n    t.bigint \"friends_too_count\", default: 0\n    t.bigint \"best_friend_id\"\n    t.bigint \"best_friend_of_id\"\n    t.bigint \"insures\", default: 0, null: false\n    t.datetime \"born_at\"\n    t.datetime \"created_at\", null: false\n    t.datetime \"updated_at\", null: false\n    t.index [\"best_friend_id\"], name: \"index_people_on_best_friend_id\"\n    t.index [\"best_friend_of_id\"], name: \"index_people_on_best_friend_of_id\"\n    t.index [\"number1_fan_id\"], name: \"index_people_on_number1_fan_id\"\n    t.index [\"primary_contact_id\"], name: \"index_people_on_primary_contact_id\"\n  end\n\n  create_table \"peoples_treasures\", id: false, force: :cascade do |t|\n    t.bigint \"rich_person_id\"\n    t.bigint \"treasure_id\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"personal_legacy_things\", force: :cascade do |t|\n    t.bigint \"tps_report_number\"\n    t.bigint \"person_id\"\n    t.bigint \"version\", default: 0, null: false\n  end\n\n  create_table \"pets\", primary_key: \"pet_id\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"owner_id\"\n    t.bigint \"integer\"\n    t.datetime \"created_at\", null: false\n    t.datetime \"updated_at\", null: false\n  end\n\n  create_table \"pets_treasures\", force: :cascade do |t|\n    t.bigint \"treasure_id\"\n    t.bigint \"pet_id\"\n    t.string \"rainbow_color\"\n  end\n\n  create_table \"pirates\", force: :cascade do |t|\n    t.string \"catchphrase\"\n    t.bigint \"parrot_id\"\n    t.bigint \"non_validated_parrot_id\"\n    t.datetime \"created_on\"\n    t.datetime \"updated_on\"\n  end\n\n  create_table \"postgresql_oids\", force: :cascade do |t|\n    t.oid \"obj_id\"\n  end\n\n  create_table \"postgresql_times\", force: :cascade do |t|\n    t.interval \"time_interval\"\n    t.interval \"scaled_time_interval\"\n  end\n\n  create_table \"postgresql_timestamp_with_zones\", force: :cascade do |t|\n    t.datetime \"time\"\n  end\n\n  create_table \"posts\", force: :cascade do |t|\n    t.bigint \"author_id\"\n    t.string \"title\", null: false\n    t.text \"body\", null: false\n    t.string \"type\"\n    t.bigint \"comments_count\", default: 0\n    t.bigint \"taggings_with_delete_all_count\", default: 0\n    t.bigint \"taggings_with_destroy_count\", default: 0\n    t.bigint \"tags_count\", default: 0\n    t.bigint \"indestructible_tags_count\", default: 0\n    t.bigint \"tags_with_destroy_count\", default: 0\n    t.bigint \"tags_with_nullify_count\", default: 0\n    t.index [\"author_id\"], name: \"index_posts_on_author_id\"\n  end\n\n  create_table \"price_estimates\", force: :cascade do |t|\n    t.string \"estimate_of_type\"\n    t.bigint \"estimate_of_id\"\n    t.bigint \"price\"\n  end\n\n  create_table \"prisoners\", force: :cascade do |t|\n    t.bigint \"ship_id\"\n    t.index [\"ship_id\"], name: \"index_prisoners_on_ship_id\"\n  end\n\n  create_table \"product_types\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"products\", force: :cascade do |t|\n    t.bigint \"collection_id\"\n    t.bigint \"type_id\"\n    t.string \"name\"\n    t.index [\"collection_id\"], name: \"index_products_on_collection_id\"\n    t.index [\"type_id\"], name: \"index_products_on_type_id\"\n  end\n\n  create_table \"projects\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"type\"\n    t.bigint \"firm_id\"\n    t.bigint \"mentor_id\"\n  end\n\n  create_table \"randomly_named_table1\", force: :cascade do |t|\n    t.string \"some_attribute\"\n    t.bigint \"another_attribute\"\n  end\n\n  create_table \"randomly_named_table2\", force: :cascade do |t|\n    t.string \"some_attribute\"\n    t.bigint \"another_attribute\"\n  end\n\n  create_table \"randomly_named_table3\", force: :cascade do |t|\n    t.string \"some_attribute\"\n    t.bigint \"another_attribute\"\n  end\n\n  create_table \"ratings\", force: :cascade do |t|\n    t.bigint \"comment_id\"\n    t.bigint \"value\"\n  end\n\n  create_table \"readers\", force: :cascade do |t|\n    t.bigint \"post_id\", null: false\n    t.bigint \"person_id\", null: false\n    t.boolean \"skimmer\", default: false\n    t.bigint \"first_post_id\"\n  end\n\n  create_table \"recipes\", force: :cascade do |t|\n    t.bigint \"chef_id\"\n    t.bigint \"hotel_id\"\n  end\n\n  create_table \"records\", force: :cascade do |t|\n  end\n\n  create_table \"references\", force: :cascade do |t|\n    t.bigint \"person_id\"\n    t.bigint \"job_id\"\n    t.boolean \"favourite\"\n    t.bigint \"lock_version\", default: 0\n  end\n\n  create_table \"sections\", force: :cascade do |t|\n    t.string \"short_name\"\n    t.bigint \"session_id\"\n    t.bigint \"seminar_id\"\n    t.index [\"seminar_id\"], name: \"index_sections_on_seminar_id\"\n    t.index [\"seminar_id\"], name: \"sections_auto_index_fk_rails_ae38e823dc\"\n    t.index [\"session_id\"], name: \"index_sections_on_session_id\"\n    t.index [\"session_id\"], name: \"sections_auto_index_fk_rails_51f4a0fcd0\"\n  end\n\n  create_table \"seminars\", force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"serialized_posts\", force: :cascade do |t|\n    t.bigint \"author_id\"\n    t.string \"title\", null: false\n  end\n\n  create_table \"sessions\", force: :cascade do |t|\n    t.date \"start_date\"\n    t.date \"end_date\"\n    t.string \"name\"\n  end\n\n  create_table \"shape_expressions\", force: :cascade do |t|\n    t.string \"paint_type\"\n    t.bigint \"paint_id\"\n    t.string \"shape_type\"\n    t.bigint \"shape_id\"\n  end\n\n  create_table \"ship_parts\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"ship_id\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"ships\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"pirate_id\"\n    t.bigint \"developer_id\"\n    t.bigint \"update_only_pirate_id\"\n    t.bigint \"treasures_count\", default: 0\n    t.datetime \"created_at\"\n    t.datetime \"created_on\"\n    t.datetime \"updated_at\"\n    t.datetime \"updated_on\"\n    t.index [\"developer_id\"], name: \"index_ships_on_developer_id\"\n  end\n\n  create_table \"shop_accounts\", force: :cascade do |t|\n    t.bigint \"customer_id\"\n    t.bigint \"customer_carrier_id\"\n    t.index [\"customer_carrier_id\"], name: \"index_shop_accounts_on_customer_carrier_id\"\n    t.index [\"customer_id\"], name: \"index_shop_accounts_on_customer_id\"\n  end\n\n  create_table \"sinks\", force: :cascade do |t|\n    t.bigint \"kitchen_id\"\n    t.index [\"kitchen_id\"], name: \"index_sinks_on_kitchen_id\"\n  end\n\n  create_table \"speedometers\", id: false, force: :cascade do |t|\n    t.string \"speedometer_id\"\n    t.string \"name\"\n    t.string \"dashboard_id\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"sponsors\", force: :cascade do |t|\n    t.bigint \"club_id\"\n    t.string \"sponsorable_type\"\n    t.bigint \"sponsorable_id\"\n    t.string \"sponsor_type\"\n    t.bigint \"sponsor_id\"\n  end\n\n  create_table \"squares\", force: :cascade do |t|\n  end\n\n  create_table \"squeaks\", force: :cascade do |t|\n    t.bigint \"mouse_id\"\n  end\n\n  create_table \"string_key_objects\", id: false, force: :cascade do |t|\n    t.string \"id\", null: false\n    t.string \"name\"\n    t.bigint \"lock_version\", default: 0, null: false\n    t.bigserial \"rowid\", null: false\n    t.index [\"id\"], name: \"index_string_key_objects_on_id\", unique: true\n  end\n\n  create_table \"students\", force: :cascade do |t|\n    t.string \"name\"\n    t.boolean \"active\"\n    t.bigint \"college_id\"\n  end\n\n  create_table \"subscribers\", id: false, force: :cascade do |t|\n    t.string \"nick\", null: false\n    t.string \"name\"\n    t.bigint \"id\"\n    t.bigint \"books_count\", default: 0, null: false\n    t.bigint \"update_count\", default: 0, null: false\n    t.bigserial \"rowid\", null: false\n    t.index [\"nick\"], name: \"index_subscribers_on_nick\", unique: true\n  end\n\n  create_table \"subscriptions\", force: :cascade do |t|\n    t.string \"subscriber_id\"\n    t.bigint \"book_id\"\n  end\n\n  create_table \"taggings\", force: :cascade do |t|\n    t.bigint \"tag_id\"\n    t.bigint \"super_tag_id\"\n    t.string \"taggable_type\"\n    t.bigint \"taggable_id\"\n    t.string \"comment\"\n    t.string \"type\"\n  end\n\n  create_table \"tags\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"taggings_count\", default: 0\n  end\n\n  create_table \"tasks\", force: :cascade do |t|\n    t.datetime \"starting\"\n    t.datetime \"ending\"\n  end\n\n  create_table \"test_with_keyword_column_name\", force: :cascade do |t|\n    t.string \"desc\"\n  end\n\n  create_table \"topics\", force: :cascade do |t|\n    t.string \"title\", limit: 250\n    t.string \"author_name\"\n    t.string \"author_email_address\"\n    t.datetime \"written_on\"\n    t.time \"bonus_time\"\n    t.date \"last_read\"\n    t.text \"content\"\n    t.text \"important\"\n    t.boolean \"approved\", default: true\n    t.bigint \"replies_count\", default: 0\n    t.bigint \"unique_replies_count\", default: 0\n    t.bigint \"parent_id\"\n    t.string \"parent_title\"\n    t.string \"type\"\n    t.string \"group\"\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"toys\", primary_key: \"toy_id\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"pet_id\"\n    t.bigint \"integer\"\n    t.datetime \"created_at\", null: false\n    t.datetime \"updated_at\", null: false\n  end\n\n  create_table \"traffic_lights\", force: :cascade do |t|\n    t.string \"location\"\n    t.string \"state\"\n    t.text \"long_state\", null: false\n    t.datetime \"created_at\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"treasures\", force: :cascade do |t|\n    t.string \"name\"\n    t.string \"type\"\n    t.string \"looter_type\"\n    t.bigint \"looter_id\"\n    t.bigint \"ship_id\"\n    t.index [\"looter_type\", \"looter_id\"], name: \"index_treasures_on_looter_type_and_looter_id\"\n    t.index [\"ship_id\"], name: \"index_treasures_on_ship_id\"\n  end\n\n  create_table \"treaties\", id: false, force: :cascade do |t|\n    t.string \"treaty_id\"\n    t.string \"name\"\n    t.bigserial \"rowid\", null: false\n  end\n\n  create_table \"trees\", force: :cascade do |t|\n    t.string \"name\"\n    t.datetime \"updated_at\"\n  end\n\n  create_table \"triangles\", force: :cascade do |t|\n  end\n\n  create_table \"tuning_pegs\", force: :cascade do |t|\n    t.bigint \"guitar_id\"\n    t.float \"pitch\"\n  end\n\n  create_table \"tyres\", force: :cascade do |t|\n    t.bigint \"car_id\"\n  end\n\n  create_table \"users\", force: :cascade do |t|\n    t.string \"token\"\n    t.string \"auth_token\"\n  end\n\n  create_table \"uuid_children\", id: :uuid, default: -> { \"gen_random_uuid()\" }, force: :cascade do |t|\n    t.string \"name\"\n    t.uuid \"uuid_parent_id\"\n  end\n\n  create_table \"uuid_items\", primary_key: \"uuid\", id: :uuid, default: nil, force: :cascade do |t|\n    t.string \"title\"\n  end\n\n  create_table \"uuid_parents\", id: :uuid, default: -> { \"gen_random_uuid()\" }, force: :cascade do |t|\n    t.string \"name\"\n  end\n\n  create_table \"variants\", force: :cascade do |t|\n    t.bigint \"product_id\"\n    t.string \"name\"\n    t.index [\"product_id\"], name: \"index_variants_on_product_id\"\n  end\n\n  create_table \"vegetables\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"seller_id\"\n    t.string \"custom_type\"\n  end\n\n  create_table \"vertices\", force: :cascade do |t|\n    t.string \"label\"\n  end\n\n  create_table \"warehouse-things\", force: :cascade do |t|\n    t.bigint \"value\"\n  end\n\n  create_table \"weirds\", force: :cascade do |t|\n    t.string \"a$b\"\n    t.string \"ใชใพใˆ\"\n    t.string \"from\"\n  end\n\n  create_table \"wheels\", force: :cascade do |t|\n    t.bigint \"size\"\n    t.string \"wheelable_type\"\n    t.bigint \"wheelable_id\"\n    t.index [\"wheelable_type\", \"wheelable_id\"], name: \"index_wheels_on_wheelable_type_and_wheelable_id\"\n  end\n\n  create_table \"zines\", force: :cascade do |t|\n    t.string \"title\"\n  end\n\n  add_foreign_key \"authors\", \"author_addresses\"\n  add_foreign_key \"fk_test_has_fk\", \"fk_test_has_pk\", column: \"fk_id\", primary_key: \"pk_id\", name: \"fk_name\"\n  add_foreign_key \"lessons_students\", \"students\", on_delete: :cascade\n  add_foreign_key \"parrots_pirates\", \"parrots\"\n  add_foreign_key \"parrots_pirates\", \"pirates\"\n  add_foreign_key \"parrots_treasures\", \"parrots\"\n  add_foreign_key \"parrots_treasures\", \"treasures\"\n  add_foreign_key \"sections\", \"seminars\"\n  add_foreign_key \"sections\", \"sessions\"\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:344

Error:
SchemaDumperTest#test_schema_dump_expression_indices:
NoMethodError: undefined method `strip' for nil:NilClass
    /Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:300:in `test_schema_dump_expression_indices'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:299

Failure:
SchemaDumperDefaultsTest#test_schema_dump_defaults_with_universally_supported_types [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:512]:
Expected /t\.datetime\s+"datetime_with_default",\s+default: "2014-06-05 07:17:04"/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"dump_defaults\", force: :cascade do |t|\n    t.string \"string_with_default\", default: \"Hello!\"\n    t.date \"date_with_default\", default: \"2014-06-05\"\n    t.datetime \"datetime_with_default\", default: \"2014-06-05 11:17:04\"\n    t.time \"time_with_default\", default: \"2000-01-01 11:17:04\"\n    t.decimal \"decimal_with_default\", precision: 20, scale: 10, default: \"1234567890.0123456789\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:507

Failure:
SchemaDumperDefaultsTest#test_schema_dump_with_float_column_infinity_default [/Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:520]:
Expected /t\.float\s+"float_with_inf_default",\s+default: ::Float::INFINITY/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"infinity_defaults\", force: :cascade do |t|\n    t.float \"float_with_inf_default\"\n    t.float \"float_with_nan_default\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/schema_dumper_test.rb:517

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/change_schema_test.rb

Error:
ActiveRecord::Migration::ChangeSchemaTest#test_change_column_quotes_column_names:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented: type conversion not yet implemented
HINT:  You have attempted to use a feature that is not yet implemented.
See: https://github.com/cockroachdb/cockroach/issues/9851
: ALTER TABLE "testings" ALTER COLUMN "select" TYPE character varying(10)
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:427:in `change_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:287:in `test_change_column_quotes_column_names'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:282

Failure:
ActiveRecord::Migration::ChangeSchemaTest#test_keeping_default_and_notnull_constraints_on_change [/Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:318]:
Expected: 100
  Actual: 99

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:297

Failure:
ActiveRecord::Migration::ChangeSchemaTest#test_create_table_with_limits [/Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:142]:
Expected: "integer"
  Actual: "bigint"

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:121

Error:
ActiveRecord::Migration::ChangeSchemaTest#test_change_column_null:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  check "foo_auto_not_null" does not exist
: ALTER TABLE "testings" ALTER COLUMN "foo" SET NOT NULL
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:442:in `change_column_null'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:353:in `change'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:814:in `exec_migration'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:797:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:796:in `migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:608:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:357:in `block (2 levels) in test_change_column_null'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:848:in `suppress_messages'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:356:in `block in test_change_column_null'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:432:in `testing_table_with_only_foo_attribute'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:350:in `test_change_column_null'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:349

Failure:
ActiveRecord::Migration::ChangeSchemaTest#test_drop_table_if_exists [/Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:419]:
Expected true to be nil or false

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:415

Failure:
ActiveRecord::Migration::ChangeSchemaTest#test_add_column_with_primary_key_attribute [/Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:31]:
Expected: 3
  Actual: 2

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:28

Failure:
ActiveRecord::Migration::ChangeSchemaTest#test_create_table_without_id [/Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:24]:
Expected: 2
  Actual: 1

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/change_schema_test.rb:22

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/relation/or_test.rb

Failure:
ActiveRecord::OrTest#test_or_when_grouping [/Users/alimi/repos/rails/activerecord/test/cases/relation/or_test.rb:95]:
--- expected
+++ actual
@@ -1 +1 @@
-[["hello", 6], ["Such a lovely day", 1]]
+[["Such a lovely day", 1], ["hello", 6]]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/relation/or_test.rb:92

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/numbers_test.rb

Failure:
PostgresqlNumberTest#test_values [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/numbers_test.rb:35]:
Expected: Infinity
  Actual: 0.0


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/numbers_test.rb:25

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Cockroach doesn't support SELECT FOR UPDATE

Hello I have an app that uses you adapter.
There is a following problem:

D, [2018-03-02T10:47:08.279117 #38] DEBUG -- : [6f444444-44d2-4aad-b9d1-ac0aae5c3fae]   Doorkeeper::AccessGrant Load (1.0ms)  SELECT  "something_access_grants".* FROM "something_access_grants" WHERE "something_access_grants"."id" = $1 LIMIT $2 FOR UPDATE  [["id", SOMEID], ["LIMIT", 1]]
D, [2018-03-02T10:47:08.279935 #38] DEBUG -- : [6f444444-44d2-4aad-b9d1-ac0aae5c3fae]    (0.6ms)  ROLLBACK
I, [2018-03-02T10:47:08.280114 #38]  INFO -- : [6f444444-44d2-4aad-b9d1-ac0aae5c3fae] Completed 500 Internal Server Error in 14ms
F, [2018-03-02T10:47:08.282341 #38] FATAL -- : [6f444444-44d2-4aad-b9d1-ac0aae5c3fae]   
F, [2018-03-02T10:47:08.282397 #38] FATAL -- : [6f444444-44d2-4aad-b9d1-ac0aae5c3fae] ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR:  syntax error at or near "for"
DETAIL:  source SQL:
SELECT  "something_access_grants".* FROM "something_access_grants" WHERE "something_access_grants"."id" = $1 LIMIT $2 FOR UPDATE

I am using cockroach cluster with version 1.1.5.
Cockroachdb does not have SELECT FOR UPDATE in its SQL dialect.
Correct me if I am wrong, but I think it does not need it since it has serialised transactions.

Can you fix your adapter to not use SELECT FOR UPDATE ?
Thanks :)

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/case_insensitive_test.rb

Failure:
PostgresqlCaseInsensitiveTest#test_case_insensitiveness [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/case_insensitive_test.rb:14]:
Expected /lower/i to match "\"defaults\".\"char1\" IS NULL".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/case_insensitive_test.rb:8

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Error with change_column_null when changing a column to NOT NULL

Example migration that fails:

class ChangePeopleNameNotNull < ActiveRecord::Migration[5.2]
  def change
    change_column_null(:people, :name, false)
  end
end
-- change_column_null(:people, :name, false)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::FeatureNotSupported: ERROR:  unimplemented at or near "null"
DETAIL:  source SQL:
ALTER TABLE "people" ALTER "name" SET NOT NULL
                                          ^
: ALTER TABLE "people" ALTER "name" SET NOT NULL
/app/db/migrate/20180709162209_change_people_name_not_null.rb:3:in `change'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
Caused by:
ActiveRecord::StatementInvalid: PG::FeatureNotSupported: ERROR:  unimplemented at or near "null"
DETAIL:  source SQL:
ALTER TABLE "people" ALTER "name" SET NOT NULL

[ActiveRecord 5.2 Test Failure] test/cases/migration/references_statements_test.rb

Error:
ActiveRecord::Migration::ReferencesStatementsTest#test_deletes_reference_type_column:
ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR:  column "supplier_id" is referenced by existing index "index_test_models_on_supplier_id_and_supplier_type"
: ALTER TABLE "test_models" DROP COLUMN "supplier_id"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:603:in `remove_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:905:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/helper.rb:38:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:106:in `block in test_deletes_reference_type_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:134:in `with_polymorphic_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:105:in `test_deletes_reference_type_column'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:104

Error:
ActiveRecord::Migration::ReferencesStatementsTest#test_deletes_polymorphic_index:
ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR:  column "supplier_id" is referenced by existing index "index_test_models_on_supplier_id_and_supplier_type"
: ALTER TABLE "test_models" DROP COLUMN "supplier_id"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:603:in `remove_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:905:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/helper.rb:38:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:113:in `block in test_deletes_polymorphic_index'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:134:in `with_polymorphic_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:112:in `test_deletes_polymorphic_index'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:111

Error:
ActiveRecord::Migration::ReferencesStatementsTest#test_does_not_delete_reference_type_column:
ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR:  column "supplier_id" is referenced by existing index "index_test_models_on_supplier_id_and_supplier_type"
: ALTER TABLE "test_models" DROP COLUMN "supplier_id"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:603:in `remove_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:905:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/helper.rb:38:in `remove_reference'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:97:in `block in test_does_not_delete_reference_type_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:134:in `with_polymorphic_column'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:96:in `test_does_not_delete_reference_type_column'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_statements_test.rb:95

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/uuid_test.rb

Error:
PostgresqlUUIDTest#test_uuid_formats:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  error in argument for $1: could not parse string "a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11" as uuid
: INSERT INTO "uuid_data_type" ("guid") VALUES ($1) RETURNING "id"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:130:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:115:in `exec_insert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:162:in `insert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:21:in `insert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:187:in `_insert_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:734:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/counter_cache.rb:184:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:140:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/callbacks.rb:346:in `block in _create_record'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:98:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:816:in `_run_create_callbacks'
    /Users/alimi/repos/rails/activerecord/lib/active_record/callbacks.rb:346:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/timestamp.rb:102:in `_create_record'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:705:in `create_or_update'
    /Users/alimi/repos/rails/activerecord/lib/active_record/callbacks.rb:342:in `block in create_or_update'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:98:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:816:in `_run_save_callbacks'
    /Users/alimi/repos/rails/activerecord/lib/active_record/callbacks.rb:342:in `create_or_update'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:275:in `save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/validations.rb:46:in `save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:310:in `block (2 levels) in save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/transaction_manager.rb:13:in `within_new_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:212:in `transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:310:in `block in save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:325:in `rollback_active_record_state!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:309:in `save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/suppressor.rb:44:in `save'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:36:in `create'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:162:in `block in test_uuid_formats'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:161:in `each'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:161:in `test_uuid_formats'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:156

Error:
PostgresqlUUIDTest#test_change_column_default:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: ALTER TABLE "uuid_data_type" ADD "thingy" uuid DEFAULT uuid_generate_v1() NOT NULL
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:581:in `add_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:420:in `add_column'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:56:in `test_change_column_default'

Error:
PostgresqlUUIDTest#test_change_column_default:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "uuid_data_type"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:42:in `block in <class:PostgresqlUUIDTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:55

Error:
PostgresqlUUIDTest#test_uniqueness_validation_ignores_uuid:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  error in argument for $1: could not parse string "a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11" as uuid
: SELECT  1 AS one FROM "uuid_data_type" WHERE "uuid_data_type"."guid" = $1 LIMIT $2
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `exec_params'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `execute_and_clear'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:478:in `select'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:70:in `select_all'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:106:in `select_all'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:77:in `select_one'
    /Users/alimi/repos/rails/activerecord/lib/active_record/relation/finder_methods.rb:322:in `block in exists?'
    /Users/alimi/repos/rails/activerecord/lib/active_record/relation.rb:584:in `skip_query_cache_if_necessary'
    /Users/alimi/repos/rails/activerecord/lib/active_record/relation/finder_methods.rb:322:in `exists?'
    /Users/alimi/repos/rails/activerecord/lib/active_record/validations/uniqueness.rb:34:in `validate_each'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validator.rb:152:in `block in validate'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validator.rb:149:in `each'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validator.rb:149:in `validate'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:816:in `_run_validate_callbacks'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validations.rb:409:in `run_validations!'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validations/callbacks.rb:118:in `block in run_validations!'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:98:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:816:in `_run_validation_callbacks'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validations/callbacks.rb:118:in `run_validations!'
    /Users/alimi/repos/rails/activemodel/lib/active_model/validations.rb:339:in `valid?'
    /Users/alimi/repos/rails/activerecord/lib/active_record/validations.rb:67:in `valid?'
    /Users/alimi/repos/rails/activerecord/lib/active_record/validations.rb:84:in `perform_validations'
    /Users/alimi/repos/rails/activerecord/lib/active_record/validations.rb:52:in `save!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:315:in `block in save!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
    /Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/transaction_manager.rb:13:in `within_new_transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:212:in `transaction'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
    /Users/alimi/repos/rails/activerecord/lib/active_record/transactions.rb:315:in `save!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/suppressor.rb:48:in `save!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/persistence.rb:53:in `create!'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:183:in `test_uniqueness_validation_ignores_uuid'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:173

Error:
PostgresqlUUIDTest#test_add_column_with_default_array:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  expected DEFAULT expression to have type uuid[], but ''{}'' has type string
: ALTER TABLE "uuid_data_type" ADD "thingy" uuid[] DEFAULT '{}'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:581:in `add_column'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:420:in `add_column'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:80:in `test_add_column_with_default_array'

Error:
PostgresqlUUIDTest#test_add_column_with_default_array:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "uuid_data_type"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:42:in `block in <class:PostgresqlUUIDTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:79

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_with_custom_default:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_with_custom_default:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:259

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:253

Error:
PostgresqlUUIDGenerationTest#test_id_is_uuid:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_id_is_uuid:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:231

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_default_in_legacy_migration:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_default_in_legacy_migration:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:274

E

Error:
PostgresqlUUIDGenerationTest#test_auto_create_uuid:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_auto_create_uuid:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:241

Error:
PostgresqlUUIDGenerationTest#test_id_has_a_default:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_id_has_a_default:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:236

Error:
PostgresqlUUIDGenerationTest#test_pk_and_sequence_for_uuid_primary_key:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_pk_and_sequence_for_uuid_primary_key:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:247

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_default:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  unknown function: uuid_generate_v1()
: CREATE TABLE "pg_uuids" ("id" uuid DEFAULT uuid_generate_v1() NOT NULL PRIMARY KEY, "name" character varying, "other_uuid" uuid DEFAULT uuid_generate_v4())
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:311:in `create_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:200:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `catch'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:199:in `block in halting'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:513:in `invoke_before'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:41:in `before_setup'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:861:in `before_setup'

Error:
PostgresqlUUIDGenerationTest#test_schema_dumper_for_uuid_primary_key_default:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "pg_uuids"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:12:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:225:in `block in <class:PostgresqlUUIDGenerationTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/uuid_test.rb:265

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/foreign_key_test.rb

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_remove_foreign_key_inferes_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:195]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:192

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_constraint_by_name:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fancy_named_fk"
name:"astronauts" id:257 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:257 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:256 name:"fancy_named_fk" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:257 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:256 name:"fancy_named_fk" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fancy_named_fk"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:280:in `test_validate_constraint_by_name'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_constraint_by_name:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:279

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_on_delete_restrict_foreign_key [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:120]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:116

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_remove_foreign_key_by_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:203]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:200

Error:
ActiveRecord::Migration::ForeignKeyTest#test_add_invalid_foreign_key:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fk_rails_78146ddd2e"
name:"astronauts" id:263 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:263 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:262 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:263 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:262 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fk_rails_78146ddd2e"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:232:in `test_add_invalid_foreign_key'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_add_invalid_foreign_key:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:231

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_infers_column:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fk_rails_78146ddd2e"
name:"astronauts" id:265 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:265 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:264 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:265 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:264 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fk_rails_78146ddd2e"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:242:in `test_validate_foreign_key_infers_column'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_infers_column:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:241

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_on_delete_cascade_foreign_key [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:135]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:131

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_foreign_key_exists_by_name [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:188]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:185

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_with_on_update [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:165]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:161

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_foreign_key_exists_by_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:181]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:178

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_inferes_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:72]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:68

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_schema_dumping_on_delete_and_on_update_options [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:313]:
Expected /\s+add_foreign_key "astronauts",.+on_update: :cascade,.+on_delete: :nullify$/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"astronauts\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"rocket_id\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:309

Error:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_is_reversible:
ArgumentError: Table 'houses' has no foreign key for {:column=>"city_id"}
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1329:in `foreign_key_for!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:991:in `remove_foreign_key'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:687:in `block in revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:812:in `exec_migration'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:797:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:796:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:336:in `block in test_add_foreign_key_is_reversible'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/stream.rb:12:in `silence_stream'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:336:in `ensure in test_add_foreign_key_is_reversible'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:336:in `test_add_foreign_key_is_reversible'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:331

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_foreign_key_exists [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:174]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:171

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_remove_foreign_key_by_name [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:219]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:216

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_remove_foreign_key_by_symbol_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:211]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:208

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_on_delete_nullify_foreign_key [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:145]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:141

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_symbol_column:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fk_rails_78146ddd2e"
name:"astronauts" id:297 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:297 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:296 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:297 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:296 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fk_rails_78146ddd2e"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:258:in `test_validate_foreign_key_by_symbol_column'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_symbol_column:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:257

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_schema_dumping [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:301]:
Expected /\s+add_foreign_key "astronauts", "rockets"$/ to match "# This file is auto-generated from the current state of the database. Instead\n# of editing this file, please use the migrations feature of Active Record to\n# incrementally modify your database, and then regenerate this schema definition.\n#\n# Note that this schema.rb definition is the authoritative source for your\n# database schema. If you need to create the application database on another\n# system, you should be using db:schema:load, not running all the migrations\n# from scratch. The latter is a flawed and unsustainable approach (the more migrations\n# you'll amass, the slower it'll run and the greater likelihood for issues).\n#\n# It's strongly recommended that you check this file into your version control system.\n\nActiveRecord::Schema.define(version: 0) do\n\n  create_table \"astronauts\", force: :cascade do |t|\n    t.string \"name\"\n    t.bigint \"rocket_id\"\n  end\n\nend\n".

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:298

Error:
ActiveRecord::Migration::ForeignKeyTest#test_foreign_key_constraint_is_not_cached_incorrectly:
ArgumentError: Table 'houses' has no foreign key for {:column=>"city_id"}
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1329:in `foreign_key_for!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:991:in `remove_foreign_key'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:687:in `block in revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:812:in `exec_migration'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:797:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:796:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:345:in `block in test_foreign_key_constraint_is_not_cached_incorrectly'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/stream.rb:12:in `silence_stream'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:345:in `ensure in test_foreign_key_constraint_is_not_cached_incorrectly'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:345:in `test_foreign_key_constraint_is_not_cached_incorrectly'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:339

Error:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_with_prefix:
ArgumentError: Table 'p_classes' has no foreign key for p_schools
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1329:in `foreign_key_for!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:991:in `remove_foreign_key'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:687:in `block in revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:812:in `exec_migration'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:797:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:796:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:365:in `block in test_add_foreign_key_with_prefix'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/stream.rb:12:in `silence_stream'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:365:in `ensure in test_add_foreign_key_with_prefix'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:366:in `test_add_foreign_key_with_prefix'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:359

Error:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_with_suffix:
ArgumentError: Table 'p_classes_s' has no foreign key for p_schools_s
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1329:in `foreign_key_for!'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:991:in `remove_foreign_key'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:871:in `block in method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `block in say_with_time'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:840:in `say_with_time'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:860:in `method_missing'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:687:in `block in revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `each'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:686:in `revert'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:812:in `exec_migration'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:797:in `block in migrate'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /Users/alimi/repos/rails/activerecord/lib/active_record/migration.rb:796:in `migrate'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:375:in `block in test_add_foreign_key_with_suffix'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/stream.rb:12:in `silence_stream'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:375:in `ensure in test_add_foreign_key_with_suffix'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:376:in `test_add_foreign_key_with_suffix'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:369

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_name:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fancy_named_fk"
name:"astronauts" id:313 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:313 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:312 name:"fancy_named_fk" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:313 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:312 name:"fancy_named_fk" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fancy_named_fk"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:266:in `test_validate_foreign_key_by_name'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_name:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:265

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_column:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  internal error: table descriptor is not valid: duplicate constraint name: "fk_rails_78146ddd2e"
name:"astronauts" id:319 parent_id:52 unexposed_parent_schema_id:29 version:1 modification_time:<> columns:<name:"id" id:1 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:false default_expr:"unique_rowid()" hidden:false > columns:<name:"name" id:2 type:<InternalType:<family:StringFamily width:0 precision:0 locale:"" visible_type:0 oid:1043 time_precision_is_set:false > > nullable:true hidden:false > columns:<name:"rocket_id" id:3 type:<InternalType:<family:IntFamily width:64 precision:0 locale:"" visible_type:0 oid:20 time_precision_is_set:false > > nullable:true hidden:false > next_column_id:4 families:<name:"primary" id:0 column_names:"id" column_names:"name" column_names:"rocket_id" column_ids:1 column_ids:2 column_ids:3 default_column_id:0 > next_family_id:1 primary_index:<name:"primary" id:1 unique:true version:1 column_names:"id" column_directions:ASC column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:false encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > indexes:<name:"index_astronauts_on_rocket_id" id:2 unique:false version:1 column_names:"rocket_id" column_directions:ASC column_ids:3 extra_column_ids:1 foreign_key:<table:0 index:0 name:"" validity:Validated shared_prefix_len:0 on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE > interleave:<> partitioning:<num_columns:0 > type:FORWARD created_explicitly:true encoding_type:0 sharded:<is_sharded:false name:"" shard_buckets:0 > disabled:false > next_index_id:3 privileges:<users:<user:"admin" privileges:2 > users:<user:"root" privileges:2 > > next_mutation_id:1 format_version:3 state:PUBLIC offline_reason:"" view_query:"" drop_time:0 replacement_of:<id:0 time:<> > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<> outbound_fks:<origin_table_id:319 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:318 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > outbound_fks:<origin_table_id:319 origin_column_ids:3 referenced_column_ids:1 referenced_table_id:318 name:"fk_rails_78146ddd2e" validity:Unvalidated on_delete:NO_ACTION on_update:NO_ACTION match:SIMPLE legacy_origin_index:2 legacy_referenced_index:1 > temporary:false 
DETAIL:  stack trace:
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1075: writeTableDescToBatch()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1048: writeTableDesc()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/table.go:1017: writeSchemaChange()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/alter_table.go:783: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:398: func2()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:143: func1()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:720: visitInternal()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:110: visit()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:74: walkPlan()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:401: startExec()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117: Start()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/execinfra/processorsbase.go:748: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/flowinfra/flow.go:370: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:405: Run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:1019: PlanAndRun()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:874: execWithDistSQLEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:767: dispatchToExecutionEngine()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:472: execStmtInOpenState()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:95: execStmt()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1368: execCmd()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1297: run()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:476: ServeConn()
/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594: func1()
/usr/local/go/src/runtime/asm_amd64.s:1357: goexit()

HINT:  You have encountered an unexpected error.

Please check the public issue tracker to check whether this problem is
already tracked. If you cannot find it there, please report the error
with details by creating a new issue.

If you would rather not post publicly, please contact us directly
using the support form.

We appreciate your feedback.

: ALTER TABLE "astronauts" ADD CONSTRAINT "fk_rails_78146ddd2e"
FOREIGN KEY ("rocket_id")
  REFERENCES "rockets" ("id")
 NOT VALID
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:967:in `add_foreign_key'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:250:in `test_validate_foreign_key_by_column'

Error:
ActiveRecord::Migration::ForeignKeyTest#test_validate_foreign_key_by_column:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "astronauts"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:52:in `block in <class:ForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:249

Failure:
ActiveRecord::Migration::ForeignKeyTest#test_add_foreign_key_with_column [/Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:86]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/foreign_key_test.rb:82

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[Tracking] Outstanding ActiveRecord 5.2 tests

Below is a list of all the ActiveRecord tests that get run against PostgreSQL on Rails 5.2. Check off tests once they're passing against master.

There will be tests that don't work against CockroachDB. To skip these tests

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

For information on running tests, see the Contributing guide.

ActiveRecord tests

  • test/cases/adapter_test.rb
  • test/cases/adapters/postgresql/active_schema_test.rb
  • test/cases/adapters/postgresql/array_test.rb
  • test/cases/adapters/postgresql/bit_string_test.rb
  • test/cases/adapters/postgresql/bytea_test.rb
  • test/cases/adapters/postgresql/case_insensitive_test.rb
  • test/cases/adapters/postgresql/change_schema_test.rb
  • test/cases/adapters/postgresql/cidr_test.rb
  • test/cases/adapters/postgresql/citext_test.rb
  • test/cases/adapters/postgresql/collation_test.rb
  • test/cases/adapters/postgresql/composite_test.rb
  • test/cases/adapters/postgresql/connection_test.rb
  • test/cases/adapters/postgresql/datatype_test.rb
  • test/cases/adapters/postgresql/date_test.rb
  • test/cases/adapters/postgresql/domain_test.rb
  • test/cases/adapters/postgresql/enum_test.rb
  • test/cases/adapters/postgresql/explain_test.rb
  • test/cases/adapters/postgresql/extension_migration_test.rb
  • test/cases/adapters/postgresql/foreign_table_test.rb
  • test/cases/adapters/postgresql/full_text_test.rb
  • test/cases/adapters/postgresql/geometric_test.rb
  • test/cases/adapters/postgresql/hstore_test.rb
  • test/cases/adapters/postgresql/infinity_test.rb
  • test/cases/adapters/postgresql/integer_test.rb
  • test/cases/adapters/postgresql/json_test.rb
  • test/cases/adapters/postgresql/ltree_test.rb
  • test/cases/adapters/postgresql/money_test.rb
  • test/cases/adapters/postgresql/network_test.rb
  • test/cases/adapters/postgresql/numbers_test.rb
  • test/cases/adapters/postgresql/partitions_test.rb
  • test/cases/adapters/postgresql/postgresql_adapter_test.rb
  • test/cases/adapters/postgresql/prepared_statements_disabled_test.rb
  • test/cases/adapters/postgresql/quoting_test.rb
  • test/cases/adapters/postgresql/range_test.rb
  • test/cases/adapters/postgresql/referential_integrity_test.rb
  • test/cases/adapters/postgresql/rename_table_test.rb
  • test/cases/adapters/postgresql/schema_authorization_test.rb
  • test/cases/adapters/postgresql/schema_test.rb
  • test/cases/adapters/postgresql/serial_test.rb
  • test/cases/adapters/postgresql/statement_pool_test.rb
  • test/cases/adapters/postgresql/timestamp_test.rb
  • test/cases/adapters/postgresql/transaction_test.rb
  • test/cases/adapters/postgresql/type_lookup_test.rb
  • test/cases/adapters/postgresql/utils_test.rb
  • test/cases/adapters/postgresql/uuid_test.rb
  • test/cases/adapters/postgresql/xml_test.rb
  • test/cases/aggregations_test.rb
  • test/cases/ar_schema_test.rb
  • test/cases/associations/cascaded_eager_loading_test.rb
  • test/cases/associations/belongs_to_associations_test.rb
  • test/cases/associations/bidirectional_destroy_dependencies_test.rb
  • test/cases/associations/callbacks_test.rb
  • test/cases/associations/eager_load_includes_ful l_sti_class_test.rb
  • test/cases/associations/eager_load_nested_include_test.rb
  • test/cases/associations/eager_singularization_test.rb
  • test/cases/associations/eager_test.rb
  • test/cases/associations/extension_test.rb
  • test/cases/associations/has_and_belongs_to_many_associations_test.rb
  • test/cases/associations/has_many_associations_test.rb
  • test/cases/associations/has_many_through_associations_test.rb
  • test/cases/associations/has_one_associations_test.rb
  • test/cases/associations/has_one_through_associations_test.rb
  • test/cases/associations/inner_join_association_test.rb
  • test/cases/associations/inverse_associations_test.rb
  • test/cases/associations/join_model_test.rb
  • test/cases/associations/left_outer_join_association_test.rb
  • test/cases/associations/nested_through_associations_test.rb
  • test/cases/associations/required_test.rb
  • test/cases/associations_test.rb
  • test/cases/attribute_decorators_test.rb
  • test/cases/attribute_methods/read_test.rb
  • test/cases/attribute_methods_test.rb
  • test/cases/attributes_test.rb
  • test/cases/autosave_association_test.rb
  • test/cases/base_test.rb (There might be problems running this test on macOS. #62)
  • test/cases/batches_test.rb
  • test/cases/binary_test.rb
  • test/cases/bind_parameter_test.rb
  • test/cases/boolean_test.rb
  • test/cases/cache_key_ test.rb
  • test/cases/calculations_test.rb
  • test/cases/callbacks_test.rb
  • test/cases/clone_test.rb
  • test/cases/coders/json_test.rb
  • test/cases/coders/yaml_column_test.rb
  • test/cases/collection_cache_key_test.rb
  • test/cases/column_alias_test.rb
  • test/cases/column_definition_test.rb
  • test/cases/comment_test.rb
  • test/cases/connecti on_adapters/schema_cache_test.rb
  • test/cases/connection_adapters/adapter_leasing_test.rb
  • test/cases/connection_adapters/connection_handler_test.rb
  • test/cases/connection_adapters/connection_specification_test.rb
  • test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
  • test/cases/connection_adapters/mysql_type_lookup_test.rb
  • test/cases/connection_adapters/type_lookup_test.rb
  • test/cases/connection_management_test.rb
  • test/cases/connection_pool_test.rb
  • test/cases/connection_specification/resolver_test.rb
  • test/cases/core_test.rb
  • test/cases/counter_cache_test.rb
  • test/cases/custom_locking_test.rb
  • test/cases/database_statements_test.rb
  • test/cases/date_test.rb
  • test/cases/date_time_precision_test.rb
  • test/cases/date_time_test.rb
  • test/cases/defaults_test.rb
  • test/cases/dirty_test.rb
  • test/cases/disconnected_test.rb
  • test/cases/dup_test.rb
  • test/cases/enum_test.rb
  • test/cases/errors_test.rb
  • test/cases/explain_subscriber_test.rb
  • test/cases/explain_test.rb
  • test/cases/finder_respond_to_test.rb
  • test/cases/finder_test.rb
  • test/cases/fixture_set/file_test.rb
  • test/cases/fixtures_test.rb (Ocassionaly fails locally. Curious to see how it does against CI.)
  • test/cases/forbidden_attributes_protection_test.rb
  • test/cases/habtm_destroy_order_test.rb
  • test/cases/hot_compatibility_test.rb
  • test/cases/i18n_test.rb
  • test/cases/inheritance_test.rb
  • test/cases/instrumentation_test.rb
  • test/cases/integration_test.rb
  • test/cases/invalid_connection_test.rb
  • test/cases/invertible_migration_test.rb
  • test/cases/json_attribute_test.rb
  • test/cases/json_serialization_test.rb
  • test/cases/locking_test.rb
  • test/cases/log_subscriber_test.rb
  • test/cases/migration/change_schema_test.rb
  • test/cases/migration/change_table_test.rb
  • test/cases/migration/column_attributes_test.rb
  • test/cases/migration/column_positioning_test.rb
  • test/cases/migration/columns_test.rb
  • test/cases/migration/command_recorder_test.rb
  • test/cases/migration/compatibility_test.rb
  • test/cases/migration/create_join_table_test.rb
  • test/cases/migration/foreign_key_test.rb
  • test/cases/migration/index_test.rb
  • test/cases/migration/logger_test.rb
  • test/cases/migration/pending_migrations_test.rb
  • test/cases/migration/references_foreign_key _test.rb
  • test/cases/migration/references_index_test.rb
  • test/cases/migration/references_statements_test.rb
  • test/cases/migration/rename_tabl e_test.rb
  • test/cases/migration_test.rb
  • test/cases/migrator_test.rb
  • test/cases/mixin_test.rb
  • test/cases/modules_test.rb
  • test/cases/multiparameter_attributes_test.rb
  • test/cases/multiple_db_test.rb
  • test/cases/nested_attributes_test.rb
  • test/cases/nested_attributes_with_callbacks_test .rb
  • test/cases/null_relation_test.rb
  • test/cases/numeric_data_test.rb
  • test/cases/persistence_test.rb
  • test/cases/pooled_connections_test.rb
  • test/cases/primary_keys_test.rb
  • test/cases/query_cache_test.rb
  • test/cases/quoting_test.rb
  • test/cases/readonly_test.rb
  • test/cases/reaper_test.rb
  • test/cases/reflection_test.rb
  • test/cases/relation/delegation_test.rb
  • test/cases/relation/merging_test.rb
  • test/cases/relation/mutation_test.rb
  • test/cases/relation/or_test.rb
  • test/cases/relation/predicate_builder_test.rb
  • test/cases/relation/record_fetch_warning_test.rb
  • test/cases/relation/where_chain_test.rb
  • test/cases/relation/where_clause_test.rb
  • test/cases/relation/where_test.rb
  • test/cases/relation_test.rb
  • test/cases/relations_test.rb
  • test/cases/reload_models_test.rb
  • test/cases/reserved_word_test.r b
  • test/cases/result_test.rb
  • test/cases/sanitize_test.rb
  • test/cases/schema_dumper_test.rb
  • test/cases/schema_loading_test.rb
  • test/cases/scoping/default_scoping_test.rb
  • test/cases/scoping/named_scoping_test.rb
  • test/cases/scoping/relation_scoping_test.rb
  • test/cases/secure_token_test.rb
  • test/cases/serialization_test.rb
  • test/cases/serialized_attribute_test.rb
  • test/cases/statement_cache_test.rb
  • test/cases/store_test.rb
  • test/cases/suppressor_test.rb
  • test/cases/tasks/database_tasks_test.rb
  • test/cases/tasks/mysql_rake_test.rb
  • test/cases/tasks/postgresql_rake_test.rb
  • test/cases/tasks/sqlite_rake_test.rb
  • test/cases/test_fixtures_test.rb
  • test/cases/time_precision_test.rb
  • test/cases/timestamp_test.rb
  • test/cases/touch_later_test.rb
  • test/cases/transaction_callbacks_test.rb
  • test/cases/transaction_isolation_test.rb
  • test/cases/transactions_test.rb
  • test/cases/type/adapter_specific_registry_test.rb
  • test/cases/type/date_time_test.rb
  • test/cases/type/integer_test.rb
  • test/cases/type/string_test.rb
  • test/cases/type/type_map_test.rb
  • test/cases/type/unsigned_integer_test.rb
  • test/cases/type_test.rb
  • test/cases/types_test.rb
  • test/cases/unconnected_test.rb
  • test/cases/unsafe_raw_sql_test.rb
  • test/cases/validations/absence_validation_test.rb
  • test/cases/validations/association_validation_test.rb
  • test/cases/validations/i18n_generate_message_validation_test.rb
  • test/cases/validations/i18n_validation_test.rb
  • test/cases/validations/length_validation_test.rb
  • test/cases/validations/presence_validation_test.rb
  • test/cases/validations/uniqueness_validation_test.rb
  • test/cases/validations_test.rb
  • test/cases/view_test.rb
  • test/cases/yaml_serialization_test.rb

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/rename_table_test.rb

Failure:
PostgresqlRenameTableTest#test_renaming_a_table_also_renames_the_primary_key_index [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/rename_table_test.rb:18]:
Expected: 1
  Actual: 0

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/rename_table_test.rb:16

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/persistence_test.rb

Error:
PersistenceTest#test_reset_column_information_resets_children:
ActiveRecord::StatementInvalid: PG::ObjectNotInPrerequisiteState: ERROR:  column "foo" in the middle of being added, try again later
: ALTER TABLE "topics" DROP COLUMN "foo"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:603:in `remove_column'
    /Users/alimi/repos/rails/activerecord/test/cases/persistence_test.rb:1261:in `ensure in test_reset_column_information_resets_children'
    /Users/alimi/repos/rails/activerecord/test/cases/persistence_test.rb:1262:in `test_reset_column_information_resets_children'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/persistence_test.rb:1247

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Active Record 5.1 Failing to insert version number

ActiveRecord::StatementInvalid: PG::InternalError: ERROR: value type int doesn't match type STRING of column "version"
: INSERT INTO "schema_migrations" (version) VALUES (20180402213849)
PG::InternalError: ERROR: value type int doesn't match type STRING of column "version"

show columns from schema_migrations;
+---------+--------+-------+---------+-------------+
|  Field  |  Type  | Null  | Default |   Indices   |
+---------+--------+-------+---------+-------------+
| version | STRING | false | NULL    | {"primary"} |
+---------+--------+-------+---------+-------------+
(1 row)

Time: 8.672796ms

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/type_lookup_test.rb

Failure:
PostgresqlTypeLookupTest#test_range_types_correctly_respect_registration_of_subtypes [/Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/type_lookup_test.rb:32]:
ActiveModel::RangeError expected but nothing was raised.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/type_lookup_test.rb:27

Error:
PostgresqlTypeLookupTest#test_array_delimiters_are_looked_up_correctly:
NoMethodError: undefined method `delimiter' for #<ActiveModel::Type::Value:0x00007ff62a360d58>
Did you mean?  limit
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/type_lookup_test.rb:14:in `block in <class:PostgresqlTypeLookupTest>'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/type_lookup_test.rb:10

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Workaround timestamp precision issue

cockroachdb/cockroach#32098 shows that Cockroachdb does not support timestamp precision (limit).

The most obvious workaround is to create the schema without a limit, e.g. remove the (#) from timestamp field on create table.

It would be nice to have the option in this adapter.

this code:

        def initialize_type_map(m = type_map)
          super(m)
          # NOTE(joey): PostgreSQL intervals have a precision.
          # CockroachDB intervals do not, so overide the type
          # definition. Returning a ArgumentError may not be correct.
          # This needs to be tested.
          m.register_type "interval" do |_, _, sql_type|
            precision = extract_precision(sql_type)
            if precision
              raise(ArgumentError, "CockroachDB does not support precision on intervals, but got precision: #{precision}")
            end
            OID::SpecializedString.new(:interval, precision: precision)
          end
        end

perhaps could be altered.

savepoint monkey-patching is obsolete

With savepoint support coming in 20.1, the customizations this library does around savepoints are no longer needed (for the new crdb version). They seem to break nested transactions.

At least:

def create_savepoint(name = "COCKROACH_RESTART"); end

https://github.com/cockroachdb/activerecord-cockroachdb-adapter/blob/f14037d3d9d7dbe5eb1ea1f46ef8eb3ca5031107/lib/active_record/connection_adapters/cockroachdb/transaction_manager.rb

Btw, maybe this library is not needed at all any more? I couldn't tell what's in in.

Error when running rails db:rollback that would result in dropping an index

Given this migration:

class CreateFoos < ActiveRecord::Migration[5.2]
  def change
    create_table :foos do |t|
      t.bigint :number
      t.references :user

      t.timestamps
    end

    add_index :foos, [:user_id, :number], unique: true
  end
end

Steps to reproduce

  • run rails db:migrate and then
  • run rails db:rollback

Expected Result

No error messages and the table and the index gone from the database.

Actual Result

The rollback throws a database error, and the index and table are not dropped from the database.

# ...
PG::InternalError: ERROR:  index "index_foos_on_user_id_and_number" is in use as unique constraint (use CASCADE if you really want to drop it)
: DROP INDEX  "index_foos_on_user_id_and_number"
# ... 

workaround

I found a workaround for it, which works for postgresql and cockroachdb, but is no permanent solution. You need to change the migration to look like this, which will yield the expected result on rollback:

class CreateFoos < ActiveRecord::Migration[5.2]
  def up
    create_table :foos do |t|
      t.bigint :number
      t.references :user

      t.timestamps
    end

    add_index :foos, [:user_id, :number], unique: true
  end

  def down
    drop_table :foos
  end
end

Not sure if this is something the adapter should be concerned with, or if this is something cockroachdb itself should deal different with (ie. like Postgres)?

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/datatype_test.rb

Error:
PostgresqlDataTypeTest#test_time_values:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:41

Error:
PostgresqlDataTypeTest#test_data_type_of_oid_types:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:37

Error:
PostgresqlDataTypeTest#test_text_columns_are_limitless_the_upper_limit_is_one_GB:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:65

Error:
PostgresqlDataTypeTest#test_data_type_of_time_types:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:32

Error:
PostgresqlDataTypeTest#test_update_oid:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:57

Error:
PostgresqlDataTypeTest#test_update_time:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:50

Error:
PostgresqlDataTypeTest#test_oid_values:
ActiveRecord::StatementInvalid: PG::InvalidDatetimeFormat: ERROR:  could not parse "1 year 2 days ago" as type interval: interval: missing unit at position 14: "1 year 2 days ago"
: INSERT INTO postgresql_times (id, time_interval, scaled_time_interval) VALUES (1, '1 year 2 days ago', '3 weeks ago')
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:21:in `setup'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/adapters/postgresql/datatype_test.rb:46

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

sequences are not being created by ActiveRecord with cockroachdb adapter

As noted here, http://www.thekidds.org/blog/2012/07/27/active-record-postgres-and-sequence-naming/, when rails generates a model with Postgres, it creates a sequence.

I am not finding that behavior to carryover into using the CockroachDB adapter. Is there something where it has to coordinate with Active Record in a specific way?

(Yes, I know we should be using UUIDs, etc., but I'm looking at how we migrate existing Rails projects that use MySQL, and I'd rather be on CockroachDB first, then fix that problem.)

[ActiveRecord 5.2 Test Failure] test/cases/migration_test.rb

Failure:
MigrationTest#test_migrator_one_up_with_unavailable_lock_using_run [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:690]:
ActiveRecord::ConcurrentMigrationError expected but nothing was raised.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:676

Failure:
MigrationTest#test_with_advisory_lock_raises_the_right_error_when_it_fails_to_release_lock [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:702]:
ActiveRecord::ConcurrentMigrationError expected but nothing was raised.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:697

Failure:
MigrationTest#test_create_table_with_query [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:526]:
Expected: 1
  Actual: 2

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:521

Failure:
MigrationTest#test_add_table_with_decimals [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:196]:
Expected 0.6e10 to be a kind of Integer, not BigDecimal.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:170

Failure:
MigrationTest#test_migrator_one_up_with_unavailable_lock [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:669]:
ActiveRecord::ConcurrentMigrationError expected but nothing was raised.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:655

Failure:
MigrationTest#test_create_table_with_query_from_relation [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:537]:
Expected: 1
  Actual: 2

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:532

Failure:
BulkAlterTableMigrationsTest#test_removing_columns [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:836]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:822

Error:
BulkAlterTableMigrationsTest#test_adding_indexes:
RuntimeError: need an expected query count for CockroachDBAdapter
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:852:in `block in test_adding_indexes'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:851:in `fetch'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:851:in `test_adding_indexes'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:840

Error:
BulkAlterTableMigrationsTest#test_changing_columns:
RuntimeError: need an expected query count for CockroachDBAdapter
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:914:in `block in test_changing_columns'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:913:in `fetch'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:913:in `test_changing_columns'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:900

Error:
BulkAlterTableMigrationsTest#test_adding_multiple_columns:
RuntimeError: need an expected query count for CockroachDBAdapter
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:803:in `block in test_adding_multiple_columns'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:802:in `fetch'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:802:in `test_adding_multiple_columns'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:797

Failure:
BulkAlterTableMigrationsTest#test_removing_index [/Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:877]:
Expected nil to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:871

Error:
ExplicitlyNamedIndexMigrationTest#test_drop_index_by_name:
ArgumentError: No indexes found on values with the options provided.
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1246:in `index_name_for_remove'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:485:in `remove_index'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:777:in `block in test_drop_index_by_name'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/assertions.rb:32:in `assert_nothing_raised'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:775:in `test_drop_index_by_name'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:769

Error:
ReservedWordsMigrationTest#test_drop_index_from_table_named_values:
ArgumentError: No indexes found on values with the options provided.
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1246:in `index_name_for_remove'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:485:in `remove_index'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:761:in `block in test_drop_index_from_table_named_values'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/assertions.rb:32:in `assert_nothing_raised'
    /Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:759:in `test_drop_index_from_table_named_values'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration_test.rb:753

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

support for activerecord 6?

Using rails 6.0.0.rc1 and I get the following on install:

  In Gemfile:
    activerecord-cockroachdb-adapter (~> 0.2) was resolved to 0.2.2, which depends on
      activerecord (~> 5.1, >= 5.1.1)

    rails (~> 6.0.0.rc1) was resolved to 6.0.0.rc1, which depends on
      activerecord (= 6.0.0.rc1)```

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/collation_test.rb

All tests fail in the setup trying to set collate to C.

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near ",": syntax error: invalid locale C: language: tag is not well-formed
DETAIL:  source SQL:
CREATE TABLE "postgresql_collations" ("id" bigserial primary key, "string_c" character varying COLLATE "C", "text_posix" text COLLATE "POSIX")

https://www.postgresql.org/docs/current/collation.html
https://www.cockroachlabs.com/docs/v19.2/collate.html

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/references_index_test.rb

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_index_for_existing_table_even_if_index_option_is_not_passed [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:79]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:73

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_index_with_options [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:50]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:44

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_index_by_default_even_if_index_option_is_not_passed [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:33]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:28

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_polymorphic_index_for_existing_table [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:98]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:92

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:25]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:20

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_polymorphic_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:60]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:55

Failure:
ActiveRecord::Migration::ReferencesIndexTest#test_creates_index_for_existing_table [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:70]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_index_test.rb:64

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/references_foreign_key _test.rb

Failure:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_removing_column_removes_foreign_key [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:149]:
"@connection.foreign_keys('testings').size" didn't change by -1.
Expected: 0
  Actual: 1

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:144

Error:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_foreign_keys_accept_options_when_changing_the_table:
NoMethodError: undefined method `primary_key' for nil:NilClass
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:122:in `block in <class:ReferencesForeignKeyTest>'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:112

Failure:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_foreign_key_column_can_be_removed [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:139]:
"@connection.foreign_keys('testings').size" didn't change by -1.
Expected: 0
  Actual: 1

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:134

Error:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_foreign_keys_can_be_created_while_changing_the_table:
NoMethodError: undefined method `from_table' for nil:NilClass
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:99:in `block in <class:ReferencesForeignKeyTest>'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:92

Failure:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_multiple_foreign_keys_can_be_removed_to_the_selected_one [/Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:225]:
"@connection.foreign_keys('testings').size" didn't change by -1.
Expected: 1
  Actual: 2

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:219

Error:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_foreign_key_methods_respect_pluralize_table_names:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  "testing" is referenced by foreign key from table "testing_parents"
: DROP TABLE IF EXISTS "testing"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:172:in `ensure in block in <class:ReferencesForeignKeyTest>'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:172:in `block in <class:ReferencesForeignKeyTest>'

Error:
ActiveRecord::Migration::ReferencesForeignKeyTest#test_foreign_key_methods_respect_pluralize_table_names:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "testings"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:80:in `block in <class:ReferencesForeignKeyTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/references_foreign_key_test.rb:154

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Error when creating table

I'm using the latest activerecord-cockroachdb-adapter gem (0.1.1).

This is my table in the migration (generated by devise):

  def change
    create_table :users do |t|
      ## Database authenticatable
      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      ## Recoverable
      t.string   :reset_password_token
      t.datetime :reset_password_sent_at

      ## Rememberable
      t.datetime :remember_created_at

      ## Trackable
      t.integer  :sign_in_count, default: 0, null: false
      t.datetime :current_sign_in_at
      t.datetime :last_sign_in_at
      t.string   :current_sign_in_ip
      t.string   :last_sign_in_ip

      ## Confirmable
      # t.string   :confirmation_token
      # t.datetime :confirmed_at
      # t.datetime :confirmation_sent_at
      # t.string   :unconfirmed_email # Only if using reconfirmable

      ## Lockable
      # t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
      # t.string   :unlock_token # Only if unlock strategy is :email or :both
      # t.datetime :locked_at

      t.boolean :premium, default: false

      t.timestamps null: false
    end

    add_index :users, :email,                unique: true
    add_index :users, :reset_password_token, unique: true
    # add_index :users, :confirmation_token,   unique: true
    # add_index :users, :unlock_token,         unique: true
  end

When I try to run the migration I get

PG::InternalError: ERROR:  type 'character varying' does not exist
: SELECT 'character varying'::regtype::oid

Heres the full stacktrace:

$ rake db:migrate
== 20170406053035 DeviseCreateUsers: migrating ================================
-- create_table(:users)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::InternalError: ERROR:  type 'character varying' does not exist
: SELECT 'character varying'::regtype::oid
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:384:in `lookup_cast_type'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/quoting.rb:110:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/quoting.rb:67:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:17:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:113:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:18:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:34:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:11:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `block in visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `map'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/Users/adam/Dropbox (Personal)/Projects/myproject/db/migrate/20170406053035_devise_create_users.rb:3:in `change'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
ActiveRecord::StatementInvalid: PG::InternalError: ERROR:  type 'character varying' does not exist
: SELECT 'character varying'::regtype::oid
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:384:in `lookup_cast_type'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/quoting.rb:110:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/quoting.rb:67:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:17:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:113:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:18:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:34:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:11:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `block in visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `map'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/Users/adam/Dropbox (Personal)/Projects/myproject/db/migrate/20170406053035_devise_create_users.rb:3:in `change'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
PG::InternalError: ERROR:  type 'character varying' does not exist
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:384:in `lookup_cast_type'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/quoting.rb:110:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/quoting.rb:67:in `quote_default_expression'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:17:in `quote_default_expression'


/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:113:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:18:in `add_column_options!'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:34:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:11:in `visit_ColumnDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `block in visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `map'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `visit_TableDefinition'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/Users/adam/Dropbox (Personal)/Projects/myproject/db/migrate/20170406053035_devise_create_users.rb:3:in `change'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/Users/adam/.rvm/gems/ruby-2.4.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

No changelog and tags

Could you provide a changelog about what changed between the different release and also tag them.

Right now on rubygems there are several releases but it's not possible to know what changed in between.

[ActiveRecord 5.2 Test Failure] test/cases/adapters/postgresql/citext_test.rb

All tests fail because the setup tries to create a citext column.

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near "citext": syntax error: type does not exist
DETAIL:  source SQL:
CREATE TABLE "citexts" ("id" bigserial primary key, "cival" citext)

https://www.postgresql.org/docs/9.1/citext.html

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/create_join_table_test.rb

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_column_options [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:66]:
Expected: [true, true]
  Actual: [true, true, false]

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:63

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:80]:
Expected: [["artist_id", "music_id"]]
  Actual: []

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:75

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_the_proper_order [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:48]:
--- expected
+++ actual
@@ -1 +1 @@
-["music_id", "video_id"]
+["music_id", "rowid", "video_id"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:45

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_set_not_null_by_default [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:30]:
Expected: [false, false]
  Actual: [false, false, false]

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:27

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_the_table_name [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:54]:
--- expected
+++ actual
@@ -1 +1 @@
-["artist_id", "music_id"]
+["artist_id", "music_id", "rowid"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:51

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:24]:
--- expected
+++ actual
@@ -1 +1 @@
-["artist_id", "music_id"]
+["artist_id", "music_id", "rowid"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:21

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_symbol_and_string [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:42]:
--- expected
+++ actual
@@ -1 +1 @@
-["artist_id", "music_id"]
+["artist_id", "music_id", "rowid"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:39

Error:
ActiveRecord::Migration::CreateJoinTableTest#test_create_and_drop_join_table_with_common_prefix:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "audio_artists_musics" does not exist
: DROP TABLE "audio_artists_musics"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:163:in `block in with_table_cleanup'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:162:in `each'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:162:in `ensure in with_table_cleanup'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:162:in `with_table_cleanup'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:137:in `test_create_and_drop_join_table_with_common_prefix'

Error:
ActiveRecord::Migration::CreateJoinTableTest#test_create_and_drop_join_table_with_common_prefix:
ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: DROP TABLE IF EXISTS "artists_musics"
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:58:in `drop_table'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:17:in `block (2 levels) in <class:CreateJoinTableTest>'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:16:in `each'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:16:in `block in <class:CreateJoinTableTest>'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `instance_exec'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:271:in `block in simple'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `block in invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `each'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:517:in `invoke_after'
    /Users/alimi/repos/rails/activesupport/lib/active_support/callbacks.rb:133:in `run_callbacks'
    /Users/alimi/repos/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:46:in `after_teardown'
    /Users/alimi/repos/rails/activerecord/lib/active_record/fixtures.rb:865:in `after_teardown'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:136

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_the_table_name_as_string [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:60]:
--- expected
+++ actual
@@ -1 +1 @@
-["artist_id", "music_id"]
+["artist_id", "music_id", "rowid"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:57

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_uuid [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:149]:
Expected: [:uuid, :uuid]
  Actual: [:uuid, :uuid, :integer]

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:147

Failure:
ActiveRecord::Migration::CreateJoinTableTest#test_create_join_table_with_strings [/Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:36]:
--- expected
+++ actual
@@ -1 +1 @@
-["artist_id", "music_id"]
+["artist_id", "music_id", "rowid"]


bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/create_join_table_test.rb:33

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

[ActiveRecord 5.2 Test Failure] test/cases/migration/index_test.rb

Failure:
ActiveRecord::Migration::IndexTest#test_rename_index_too_long [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:49]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:40

Failure:
ActiveRecord::Migration::IndexTest#test_double_add_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:54]:
[ArgumentError] exception expected, not
Class: <ActiveRecord::StatementInvalid>
Message: <"PG::InternalError: ERROR:  duplicate index name: \"some_idx\"\n: CREATE  INDEX  \"some_idx\" ON \"testings\"  (\"foo\")">
---Backtrace---
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `exec'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/Users/alimi/repos/rails/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/Users/alimi/repos/rails/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
/Users/alimi/.rvm/rubies/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
/Users/alimi/repos/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute'
/Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index'
/Users/alimi/repos/activerecord-cockroachdb-adapter/lib/active_record/connection_adapters/cockroachdb/schema_statements.rb:8:in `add_index'
/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:55:in `block in test_double_add_index'
---------------

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:52

Error:
ActiveRecord::Migration::IndexTest#test_add_index:
ArgumentError: No indexes found on testings with the options provided.
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:1246:in `index_name_for_remove'
    /Users/alimi/repos/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:485:in `remove_index'
    /Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:153:in `test_add_index'

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:151

Failure:
ActiveRecord::Migration::IndexTest#test_internal_index_with_name_matching_database_limit [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:86]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:82

Failure:
ActiveRecord::Migration::IndexTest#test_add_partial_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:203]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:201

Failure:
ActiveRecord::Migration::IndexTest#test_index_exists_on_multiple_columns [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:108]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:105

Failure:
ActiveRecord::Migration::IndexTest#test_unique_index_exists [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:126]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:123

Failure:
ActiveRecord::Migration::IndexTest#test_add_index_attribute_length_limit [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:148]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:145

Failure:
ActiveRecord::Migration::IndexTest#test_index_symbol_names [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:92]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:90

Failure:
ActiveRecord::Migration::IndexTest#test_remove_named_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:140]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:137

Failure:
ActiveRecord::Migration::IndexTest#test_rename_index [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:37]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:31

Failure:
ActiveRecord::Migration::IndexTest#test_named_index_exists [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:132]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:129

Failure:
ActiveRecord::Migration::IndexTest#test_index_exists_with_custom_name_checks_columns [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:113]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:111

Failure:
ActiveRecord::Migration::IndexTest#test_index_exists [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:101]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:98

Failure:
ActiveRecord::Migration::IndexTest#test_add_index_works_with_long_index_names [/Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:66]:
Expected false to be truthy.

bin/rails test Users/alimi/repos/rails/activerecord/test/cases/migration/index_test.rb:63

See the Contributing Guide for instructions on running tests.

If the test isn't valid against CockroachDB

  1. Add a ruby file to test/excludes that matches the name of the test class if one doesn't already exist. For example to exclude a test from ActiveRecord::AdapterTest, create test/excludes/ActiveRecord/AdapterTest.rb.
  2. Add an exclude statement to the file with the name of the test to exclude and a description. For example to exclude test_indexes from ActiveRecord::AdapterTest:
    exclude :test_indexes, "Rails transactional tests are being used while making schema changes. See https://www.cockroachlabs.com/docs/stable/online-schema-changes.html#limited-support-for-schema-changes-within-transactions."
  3. Finally, if the test can run against CockroachDB with a few changes, add it to test/cases. Everything from the ActiveRecord test suite will be available, so a lot of the excluded test can be copied over. Namespace the test under the CockroachDB module to avoid name collisions. See test/cases/adapter_test.rb for an example.

See #48.

Support db:structure:dump and db:structure:load

The Postgres DatabaseTasks implementation uses pg_dump to dump the database in db:structure:dump. CockroachDB doesn't support pg_dump, so this plugin should use DUMP and its inverse when they're officially supported.

Uuid for unique ids in Rails 5.x fails due to direct inheritance with PostgreSQL adapter

Rails 5.x has first class support for uuid as unique ID for objects. PostgreSQL 9.4+ has a direct support of that through a call to gen_random_uuid() in the create query :

CREATE TABLE "users" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "email" character varying, [...]

Unfortunately that function doesn't exist in the case of cockroachdb. Instead, as pointed out in the documentation (https://www.cockroachlabs.com/docs/v1.1/uuid.html#create-a-table-with-auto-generated-unique-row-ids) uuid_v4()::UUID() should be used.

a quick work around

As described in the postgresql adapter code (https://github.com/rails/rails/blob/8f037a5ab929f929fe0897edc9ecadf901c32e56/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb#L7-L45) it's possible to pass a custom function name to handle uuid generation.

So, to get through with the create the migration should look like this :

create_table :users, id: false do
  t.primary_key :id, :uuid, default: "uuid_v4()::UUID"
  [...]
end

permanent fix

I'd guess one needs to add something similar to https://github.com/rails/rails/blob/8f037a5ab929f929fe0897edc9ecadf901c32e56/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb#L46-L52 for this adapter. I might have a try if someone can validate this thought.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.