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.8-py3-none-win_amd64.whl (4.3 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

colref-0.7.8-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.8-py3-none-win_amd64.whl.

File metadata

  • Download URL: colref-0.7.8-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.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 39a4a3d4063e87d9833020c874cedb29e6c30468ec666785e2759e606820b589
MD5 8c91dc2f41a04233beb5421e9991e967
BLAKE2b-256 d00dfc3ff468f5a473e70832b70bfed3c1d773ccd02ba577e19707311d0c92b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.8-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.8-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for colref-0.7.8-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ff9fda1273e226a6ea0e77df6d818448406a57e9ab9d723d37a71729e635a354
MD5 0f5a3b693483747f59751c5767943440
BLAKE2b-256 fe57b24bac5d2f37870bfcaa1ea9fbd8c09ccd89a0e2ef06b043a4ffc3d8c2b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.8-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.8-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for colref-0.7.8-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8e9704332f216d440720ecc2c950f0ff9e69ef76f87398ef9f0c1879350bd3a8
MD5 982006fdf06c3988dc1382b81bb5bf62
BLAKE2b-256 33478bc18921646e43815c513b47e4d38f9e5f2be713c7e7e2afdb82dc2f537f

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.8-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.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for colref-0.7.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2321806175011df41f23726314ddac22f329e2d8745ba5c474d0c3a3ff60711
MD5 7464e99e2cdf729795e98a5a4b7d115d
BLAKE2b-256 66cfea97fb300d09d26a757f64687cfc2c30aa5cc21679e664578c00d9a54982

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.8-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.8-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for colref-0.7.8-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6f7db0c9668f8e64a45035754253b272785104f1fafb6dbf63a685bfad3c1cc8
MD5 6091e089dc251d0e9081efd76086510c
BLAKE2b-256 94bbd3222bd3a13420f559153cb585c1c83806a01b01d1a4d50d966c03f1de9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for colref-0.7.8-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