Skip to content

feat: composite primary keys - #45

Merged
seuros merged 5 commits into
masterfrom
fix/composite-primary-keys
Aug 10, 2026
Merged

feat: composite primary keys#45
seuros merged 5 commits into
masterfrom
fix/composite-primary-keys

Conversation

@seuros

@seuros seuros commented Aug 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

seuros added 5 commits August 10, 2026 23:45
rails_lens:annotate[Foo] only applied the filter to the ActiveRecord
source; external sources (e.g. ActiveCypher graph models) ignored it and
annotated everything on every run. The rake task also suppressed
zero-count source lines and annotate_source swallowed source errors
unless verbose, so a filter that matched nothing (like the misread
rails_lens:annotate[models]) reported only the graph source line and
looked like AR annotation silently skipped models.

- filter_models_by_names enforces options[:models] centrally for every
  source, matching class name or table name
- always print per-source counts, including zeros
- warn with usage hint when a models filter matches nothing
- record source-level errors in results[:failed] instead of dropping them
Use model.primary_key (an Array for composite keys since Rails 7.1)
in the CompositeKeys analyzer instead of the legacy primary_keys
reader and a raw pg_index query. Schema adapters switch from
connection.primary_key (returns nil for composite keys) to
connection.primary_keys so composite columns are marked pk = true.

Dummy model annotations regenerated accordingly.
…ilience

- determine_keys handles Array primary/foreign keys so composite PK
  columns get PK/FK markers
- group_by_database option writes one erd_<db>.mmd per connection;
  generate_erd command reports every generated file
- extracted renderable? guard: a model whose connection is down is
  skipped instead of aborting the whole diagram
…harness

- route/mailer annotators skip writing when file content is unchanged
  (new annotation_idempotence_test covers schema/route/mailer)
- ErrorReporter read RailsLens.verbose/debug/raise_on_error which do
  not exist on the module; go through RailsLens.config
- expose RailsLens.config_file for the loaded config path
- Rakefile runs each test file in its own process: `ruby a.rb b.rb`
  only executes the first file, so most of the suite never ran
- fix stale test assertions (TOML sections, NoteCodes, mermaid
  relationship lines) and un-skip the multi-database annotation test
The old Rakefile only executed the first test file, so the full suite
had never run on CI. Running it everywhere surfaced Rails 7.2
incompatibilities (ActiveRecord::ConnectionNotDefined, activerecord-
postgis, PostGIS schema DSL); drop 7.2 instead of shimming around it.

- gemspec: activerecord/railties >= 8.0.0
- CI matrix: 8.0, 8.1, edge (rails/rails main, future 8.2,
  non-blocking); Gemfile supports RAILS_VERSION=edge
- CI: db:schema:load instead of no-op db:migrate — there are no
  migration files and only Rails >= 8.1 test_help loads the
  per-database schema dumps implicitly
- ERD: an entity that fails to be added no longer crashes relationship
  generation; relationships only reference entities present in the
  diagram
- ColumnTypeFormatter falls back to sql_type/'unknown' when
  column.type is nil (unresolvable custom types)
- eager-reference lazy-loaded models in the abstract-class test so
  .descendants is populated regardless of test order

BREAKING CHANGE: Rails 7.2 is no longer supported; require Rails 8.0+.
@seuros
seuros force-pushed the fix/composite-primary-keys branch from dcca312 to b660f88 Compare August 10, 2026 23:34
@seuros
seuros merged commit 8d934b5 into master Aug 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant