dogweather

dogweather

I realized I could really use something like this in my Phoenix project:

https://github.com/gregnavis/active_record_doctor

I asked Claude 4 Sonnet if a port exists - it said no, and gave me this rundown:

Summary

Great question! Active Record Doctor is indeed fantastic for Rails apps. Here’s what exists in the Phoenix/Elixir and PostgreSQL worlds:

1. Phoenix/Elixir World

Unfortunately, there’s no direct equivalent to Active Record Doctor for Phoenix/Ecto yet. However, there are some tools that provide partial coverage:

Ecto-specific Tools:

  • Ecto.Linter - Basic linting for Ecto schemas and queries (though less active)
  • Boundary - Architectural analysis (not database-focused)
  • Credo - Code analysis that includes some database-related checks

What’s Missing:

The Phoenix ecosystem could really use a tool that checks for:

  • Missing foreign key constraints
  • Missing indexes on associations
  • Schema/validation mismatches
  • Unused indexes
  • Missing presence validations for NOT NULL columns

This would be a great open-source opportunity for someone to build an “Ecto Doctor” equivalent!

2. PostgreSQL Level

There are several excellent PostgreSQL-native tools:

Schema Analysis:

Database Health:

Custom Queries:

You can write PostgreSQL queries to detect many issues Active Record Doctor finds:

-- Find tables without primary keys
SELECT schemaname, tablename 
FROM pg_tables 
WHERE schemaname = 'public' 
AND tablename NOT IN (
  SELECT tablename 
  FROM pg_indexes 
  WHERE indexname LIKE '%_pkey'
);

-- Find foreign keys without indexes
SELECT conname, conrelid::regclass, confrelid::regclass
FROM pg_constraint 
WHERE contype = 'f' 
AND NOT EXISTS (
  SELECT 1 FROM pg_index 
  WHERE indrelid = conrelid 
  AND indkey[0] = conkey[1]
);

Recommendation

For your Phoenix app, I’d suggest:

  1. Create custom Mix tasks that run PostgreSQL queries to detect common issues
  2. Build a simple “Ecto Doctor” - this could be a valuable contribution to the community
  3. Use PostgreSQL-native tools for performance and schema analysis

Given your appreciation for C.J. Date’s rigorous approach to database design, you might actually enjoy building such a tool - it would enforce good relational practices in the Elixir ecosystem!

Showing Posts 1 to 2

kevinschweikert

kevinschweikert

There is Ecto PSQL Extras — ecto_psql_extras v0.8.8 and the same exists for MySQL and SQLite

Schultzer

Schultzer

Nothing like that exists for Ecto, most of this could be done in a mix of runtime and compiletime.

One of my goal with SQL is to provide most of this at compiletime.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews