feat: add @pgpm/geolite — GeoLite2 IP geolocation module#76
Open
pyramation wants to merge 2 commits into
Open
Conversation
- geolite schema with tables: network, location, asn, data_version (all with uuidv7 PKs) - GiST indexes on network and asn for fast CIDR containment lookups (>>=) - Lookup functions: geolite.lookup(inet) and geolite.lookup_asn(inet) - All tables globally readable (GRANT SELECT TO public) - TypeScript loader: downloads .mmdb from P3TERX/GeoLite.mmdb, walks MMDB trie, bulk-loads via COPY - Follows pgpm module conventions (deploy/revert/verify triplets)
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
@pgpm/geolite— a new pgpm module providing GeoLite2 IP geolocation tables and lookup functions for PostgreSQL.pgpm extension (schema DDL, deployed via
pgpm deploy):geolite.network— CIDR blocks → geoname locations + lat/long/accuracy (~4M rows for City IPv4), GiST indexed for>>=containment lookupsgeolite.location— geoname_id → country/city/subdivision/timezone metadata, UNIQUE on(geoname_id, locale_code)geolite.asn— CIDR blocks → autonomous system number/organization, GiST indexedgeolite.data_version— tracks loaded release versiongeolite.lookup(inet)/geolite.lookup_asn(inet)— convenience functions joining network + locationuuidv7()primary keys andGRANT SELECT TO publicfor global readabilityTypeScript loader (
src/loader.ts):.mmdbfiles from P3TERX/GeoLite.mmdb (no MaxMind account required)COPYfor fast bulk loadingTRUNCATE+COPYfor atomic reload; re-runnable for weekly updates--ipv6flag for including IPv6 blocksRef: https://github.com/constructive-io/constructive-planning/issues/356
Review & Testing Checklist for Human
GRANT SELECT TO publicis the right access level for your use casepgpm deploy) and run the loader (DATABASE_URL=... pnpm geolite:load) to confirm end-to-endSELECT * FROM geolite.lookup('8.8.8.8'::inet))Notes
--ipv6.cidr+ GiST — no ip4r or PostGIS dependencies. ip4r can be added later for high-throughput use cases.maxmindandpg-copy-streamsare devDependencies since the loader runs outside pgpm's deploy lifecycle.Link to Devin session: https://app.devin.ai/sessions/351581b79f0945ffbf53e0912b40a374
Requested by: @pyramation