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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

colref-0.7.9-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.9-py3-none-win_amd64.whl.

File metadata

  • Download URL: colref-0.7.9-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.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 899c7fb47ad5de2281958af0cbdc38e80d9ca161082304282a83e5db7a0375cf
MD5 6bd47d9daa3dda48a98fbb188a084ef8
BLAKE2b-256 bd6d577b52e73f7a3f938f667e2692b58a8b39a6bc27c394a01df42a74f84cb0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colref-0.7.9-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 67bb3438f693b36880022d7ce2d480e000d48c49b0c5ffdc656a3023c03932cd
MD5 d5b4de9c0391917f658d0167b9bad3dd
BLAKE2b-256 c8d9bccbebec4d901d142ee3c097f89964aaac56e2460eccb71bf513762c90ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colref-0.7.9-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 34ad4293b2f3d0c9a1917e18193623ec4720a7b6d974fbbc29e3e48d39167054
MD5 32846861dd9297def426758256dedef7
BLAKE2b-256 5a79316105ffe2ae3277b11d207d41eb7b10d0f9745c928f0b46da162d4834ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colref-0.7.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30703833481f555156752078cdf4831be92adeef37f814f76d076ab0c7dc384e
MD5 8768472f0f80f8ec7cf1869e06db9e7a
BLAKE2b-256 8fcec610a6c06cf0c4491b1c3ff93d271792653163a38174c5dfb014b3cf0312

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colref-0.7.9-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 236ebae66d73ee549b7a92097139001b211b547530eb688ef0a117a4a416e78d
MD5 cae0eeae5a27b5a47fc1a395cd9b1d4b
BLAKE2b-256 da540f8c34add2e44c8cda4d6d90680211c6693e368735fd0ef626fd10576424

See more details on using hashes here.

Provenance

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