This Ruby gem is greatly influenced by the Scenic, F(x) and ActiveRecord::PostgtresEnum projects but takes some steps further.
In addition to the support of different objects, we are solving a problem of interdependency between them. For example, you can create a table, then a function using its type as an argument, then check constraint and index using the function.
Another difference from the aforementioned gems is that we explicitly register all objects created by migrations in the special table (pg_trunk
). That lets us distinguish objects created by “regular” migration from temporary ones added manually and exclude the latter from the schema. We bind any object to a particular version of migration that added it. That’s how only those objects that belong to the current branch are dumped into the schema.rb
.
As of today, we support the creation, modification, and dropping of the following objects:
- tables
- indexes
- foreign keys (including multi-column ones)
- check constraints
- views
- materialized views
- functions
- procedures
- triggers
- custom statistics
- enumerable types
- composite types
- domains types
- rules
- sequences
For tables
and indexes
we reuse the ActiveRecord’s native methods. For check constraints
and foreign keys
, we support both the native definitions inside the table and standalone methods (like create_foreign_key
) with additional features. The other methods are implemented from scratch.
In the future, other objects like aggregate functions, range types, operators, collations, and more will be supported.