Skip to main content

Check whether a database column is still referenced in your codebase before you delete it

Project description

colref

Test codecov Go Report Card Go Reference License: MIT Gem Version PyPI version

Check whether a database column is still referenced in your codebase before you delete it.

Why

You want to remove a column from a long-running system. The column looks unused, but you're not sure. A full-text search returns hits inside comments, test fixtures, and migration history — noise that makes it hard to tell whether the column is actually read or written in live code.

colref scans your codebase with an AST parser, skips comments and string literals, and tells you where the column is referenced. If it finds nothing, you have a concrete starting point for the deletion decision. The final call is yours.

Installation

pip / pipx (Python users)

If you are working on a Django or Python project, the easiest way to install colref is via pip or pipx. No Go installation required.

pipx install colref

Or with pip:

pip install colref
OS x86_64 (Intel/AMD) arm64
macOS ✓ (Apple Silicon)
Linux
Windows

gem (Ruby users)

If you are working on a Rails or Ruby project, install via gem. No Go installation required.

gem install colref

Homebrew (macOS and Linux)

brew install shinagawa-web/tap/colref

If you prefer to tap first:

brew tap shinagawa-web/tap
brew install colref

One-line installer (Linux and macOS)

curl -fsSL https://raw.githubusercontent.com/shinagawa-web/colref/main/install.sh | sh

Manual download

Pre-built binaries are available on the releases page.

For full installation options, see Getting started.

Usage

colref check --orm <orm> --model <Model> --field <field> [path]

path is the project root to scan (default: current directory).

Flag Description
--orm ORM type: django, rails (required)
--model Model name to look up (required)
--field Field name to search for (required)

Example:

$ colref check --orm django --model Page --field seo_title
Scanning 932 files...

References found for Page.seo_title

  wagtail/admin/tests/pages/test_create_page.py:1867   page.seo_title
  wagtail/admin/tests/pages/test_create_page.py:1892   page.seo_title

For ORM-specific behavior and more examples, see Django and Rails.

Limitations

colref uses static AST analysis and cannot detect every reference pattern. References where the field name is constructed at runtime (e.g. getattr(obj, field_name)) are out of scope by design.

If colref reports no references, treat it as "none found by the scanner" — not as a guarantee the column is unused.

For the full per-pattern breakdown, see Detection patterns and Limitations.

Roadmap

See issue #74.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

colref-0.7.10-py3-none-win_amd64.whl (4.3 MB view details)

Uploaded Python 3Windows x86-64

colref-0.7.10-py3-none-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

colref-0.7.10-py3-none-manylinux_2_34_aarch64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

colref-0.7.10-py3-none-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

colref-0.7.10-py3-none-macosx_10_9_x86_64.whl (4.5 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file colref-0.7.10-py3-none-win_amd64.whl.

File metadata

  • Download URL: colref-0.7.10-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for colref-0.7.10-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8b94d90e70c3d9c2b46048ebf0a7227c5766d12b8f9a6ea90c190d9507c424bc
MD5 e1b72050b3e2a477dbb184165e075c18
BLAKE2b-256 5297c5adf746eedfa8b7d376616663ac6e33c8aefd4a43a00eaf0952f6dbb597

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.10-py3-none-win_amd64.whl:

Publisher: release.yml on shinagawa-web/colref

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colref-0.7.10-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for colref-0.7.10-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b653ba26c071947eadc902cec08d2626db617a749de4357dbdd15f8f5e46e9ce
MD5 b5a3e2f85907b656850cf7ade1a8d849
BLAKE2b-256 6670bac20d95841e2424cf4522789f8357d29335ed370f7487439b2a1e5f6c7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.10-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on shinagawa-web/colref

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colref-0.7.10-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for colref-0.7.10-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 9f480fb523fbfb4ea5ed1f88da891a4ee224ed097867c4f9bdda2de28f3b7dab
MD5 a0c5e59d0f738274f3a5307841608229
BLAKE2b-256 81f44932ba5714a3336c86a53255972a590d402308a6c736660f4c5fb27b2926

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.10-py3-none-manylinux_2_34_aarch64.whl:

Publisher: release.yml on shinagawa-web/colref

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colref-0.7.10-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for colref-0.7.10-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b528b58db4381b732eda13c2a69b71cca80c8b6ea919cc89f5b06939296872ae
MD5 227170943a370a9bcea52cf9d4a8a28c
BLAKE2b-256 cd8808c0e4483169e84d33195b5c17a7e6f63e3d8172dbcb57f3ab61bbce8eb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.10-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on shinagawa-web/colref

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colref-0.7.10-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for colref-0.7.10-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 287eafc8d0b30e93a01442d13eacdccff1943b3417ac158014fabb253ab6e2b4
MD5 686101b4027b6a3018e69ed3bf7ef6e4
BLAKE2b-256 aba333a980c3016797ed7370a75ef8433a27a2508b5b96d9c4896bea3329363e

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.10-py3-none-macosx_10_9_x86_64.whl:

Publisher: release.yml on shinagawa-web/colref

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page