ActiveRecord adapter extension for ProgreSQL — teaches ActiveRecord to express and round-trip the fork's schema features so schema.rb stays canonical.
ProgreSQL is a PostgreSQL fork that adds GLOBAL spanning indexes (true cross-partition / cross-inheritance-child PRIMARY KEY / UNIQUE) and cross-child foreign keys (a FK to an inheritance/partition root that resolves into any typed child). Those features need DDL that vanilla ActiveRecord can neither emit nor dump. active_record-progresql closes that gap.
Composes with active_record-mti (which owns the inherits: DSL). active_record-mti provides the inheritance hierarchy; active_record-progresql provides the spanning/GLOBAL primitives over it (and over declarative partitioning, independently).
create_table :data, id: :uuid, primary_key: { global: true } # PRIMARY KEY (id) GLOBAL
add_index :entity, :id, unique: true, global: true # UNIQUE (id) GLOBAL
t.index :id, unique: true, global: trueglobal:on indexes / primary keys → appends theGLOBALkeyword. Omitted → a normal LOCAL index (unchanged).- Schema-dumper round-trip →
db:schema:dumpre-emitsglobal: true, soschema.rbdoesn't silently lose the fork features (the reason you'd otherwise be forced ontoschema_format = :sql). This is the load-bearing feature. - Cross-child FKs need no new DSL — a standard
add_foreign_keyto a root resolves into children automatically because the referenced index is GLOBAL. The only primitive isglobal:.
Auto-derivable from the inheritance tree + FK graph (or declarable explicitly):
| Table role | Index |
|---|---|
| inheritance / partition root | PRIMARY KEY (id) GLOBAL |
| FK-target sub-root with children | UNIQUE (id) GLOBAL |
| FK-target leaf | LOCAL UNIQUE (id) — cheaper, ON CONFLICT-able; auto-satisfied by the root GLOBAL PK |
| leaf that later gains time-bucket children | upgrade its UNIQUE (id) LOCAL → GLOBAL |
The validated target output is db/structure.sql in the claudepilot monorepo — the real fact-web schema (23 tables / 101 FKs / 3 spanning indexes), already loaded clean against ProgreSQL. The gem's DSL → SQL output should reproduce it, and a dump of a database built from it should round-trip back to the same schema.rb.
🚧 Scaffold. Structure + design are in place; implementation is TODO (see the TODO(agent) markers in lib/active_record/progresql/connection_adapters/postgresql/). Build TDD against the golden fixture.
Build order:
global:onadd_index/ index DDL emit (schema_statements.rb).- global primary key on
create_table. - schema-dumper round-trip (
schema_dumper.rb) — the bit that unlocksschema.rb. - (optional) auto-placement from the inheritance + FK graph.
bundle install
rake spec # rspec (combustion test app against a ProgreSQL instance)Integration specs run against a live ProgreSQL build (>= the progresql-c1 root-first-GLOBAL fix). active_record-mti is a dev dependency for the inheritance-hierarchy fixtures.
MIT — see LICENSE.txt.