What we’ve got here is a collection of extensions to the ActiveRecord PostgreSQL adapter including:
-
support for constraints in migrations including CHECK constraints, foreign keys, unique constraints and so forth. Constraints can be added per column and per table.
-
some methods for manipulating all sorts of stuff like procedural languages, functions, sequences, views, schemas, triggers, types, extensions, materialized views and event triggers.
-
better support for creating indexes with expressions so you can use functions and GiST and GIN indexes.
-
support for manipulating role privileges.
-
support for some PostgreSQL-specific statements like INHERITS and LIKE when creating tables.
-
support for automatically detecting foreign key relationships and building ActiveRecord associations accordingly. This associations can be overridden as necessary and are sane enough that they won’t try to overwrite existing associations.
-
support for some PostGIS functionality including some support for using PostGIS columns in migrations. For manipulating PostGIS data, see our activerecord-spatial gem at github.com/zoocasa/activerecord-spatial or the RGeo project at github.com/dazuma/rgeo .
While this extension has support for creating a bunch of PostgreSQL-specific DDL statements, it can’t actually reverse the process yet to create the Ruby equivalent code in your schema.rb file. To create a suitable schema file that you can use for creating test databases or just to view the schema itself, you can try switching the ActiveRecord configuration option for schema_format from :ruby to :sql like so:
config.active_record.schema_format = :sql
This will tell ActiveRecord to use the pg_dump utility to create a file containing the database schema in db/development_structure.sql.
Details on this configuration option can be found here:
guides.rubyonrails.org/configuring.html
This gem is licensed under an MIT-style license. See the MIT-LICENSE
file for details.