This document audits every database table and field against actual code usage to identify what's truly needed vs unused/legacy code.
checkins
- Main check-in recordsaddress_cache
- Cached address dataprofile_cache
- User profile datauser_follows
- Following relationshipsanchor_users
- User tracking for crawlingprocessing_log
- Processing statisticsoauth_sessions
- Authentication sessionsdisplay_names
- Display name tracking
checkins_v1
- Legacy versionaddress_cache_v1
- Legacy versionuser_pdses
- PDS trackingmigrations
- Migration tracking
Status: ✅ ACTIVE - Core table used extensively by API
id
(TEXT, PRIMARY KEY) - ✅ USED - Required for record identificationuri
(TEXT, UNIQUE) - ✅ USED - AT Protocol record URI, used in API responsesrkey
(TEXT) - ✅ USED - Record key, used for queriesdid
(TEXT) - ✅ USED - Author DID, used for user filtering and querieshandle
(TEXT) - ✅ USED - Author handle, displayed in API responsesdisplay_name
(TEXT) - ✅ USED - Author display name, used in API responsesavatar
(TEXT) - ✅ USED - Author avatar URL, used in API responsestext
(TEXT) - ✅ USED - Check-in message, core contentcreated_at
(TEXT) - ✅ USED - Timestamp for sorting and cursorslatitude
(REAL) - ✅ USED - Location coordinate, used for distance calculationslongitude
(REAL) - ✅ USED - Location coordinate, used for distance calculationsvenue_name
(TEXT) - ✅ USED - UNIFIED FIELD - Venue name displayed in APIcategory
(TEXT) - 🤔 STORED - Place category, not currently used in API responsescategory_group
(TEXT) - 🤔 STORED - Category group, not currently used in API responsescategory_icon
(TEXT) - 🤔 STORED - Category icon, not currently used in API responsesaddress_street
(TEXT) - ✅ USED - Street address, used in API responsesaddress_locality
(TEXT) - ✅ USED - City, used in API responsesaddress_region
(TEXT) - ✅ USED - State/province, used in API responsesaddress_country
(TEXT) - ✅ USED - Country, used in API responsesaddress_postal_code
(TEXT) - ✅ USED - Postal code, used in API responsesindexed_at
(TEXT) - ✅ USED - Metadata timestamp
Migration Impact: Migration 005 removed these unused fields:
address_ref_uri
- ❌ REMOVED - StrongRef URI, not used in APIaddress_ref_cid
- ❌ REMOVED - StrongRef CID, not used in APIaddress_full
- ❌ REMOVED - JSON field causing parsing issuesaddress_resolved_at
- ❌ REMOVED - Resolution timestamp, not usedplace_name
- ❌ REMOVED - Migrated to unifiedvenue_name
cached_address_name
- ❌ REMOVED - Migrated to unifiedvenue_name
Status: ❓ UNCLEAR - Table exists but usage uncertain
uri
(TEXT, PRIMARY KEY) - ❓ UNKNOWN - Address record URIcid
(TEXT) - ❓ UNKNOWN - Content hashname
(TEXT) - ❓ UNKNOWN - Venue namestreet
(TEXT) - ❓ UNKNOWN - Street addresslocality
(TEXT) - ❓ UNKNOWN - Cityregion
(TEXT) - ❓ UNKNOWN - State/provincecountry
(TEXT) - ❓ UNKNOWN - Countrypostal_code
(TEXT) - ❓ UNKNOWN - Postal codelatitude
(REAL) - ❓ UNKNOWN - Location coordinatelongitude
(REAL) - ❓ UNKNOWN - Location coordinateresolved_at
(TEXT) - ❓ UNKNOWN - Resolution timestamp
Migration Impact: Migration 006 removed:
full_data
- ❌ REMOVED - JSON field causing parsing issuesfailed_at
- ❌ REMOVED - Failure timestamp, not used
Status: ✅ ACTIVE - Used by ProfileResolver in API
did
(TEXT, PRIMARY KEY) - ✅ USED - User DID, key for profile lookupshandle
(TEXT) - ✅ USED - User handle, displayed in APIdisplay_name
(TEXT) - ✅ USED - Display name, shown in API responsesavatar_url
(TEXT) - ✅ USED - Avatar URL, used in API responsesdescription
(TEXT) - 🤔 STORED - Profile description, not used in API responsesfollowers_count
(INTEGER) - 🤔 STORED - Follower count, not used in API responsesfollowing_count
(INTEGER) - 🤔 STORED - Following count, not used in API responsesposts_count
(INTEGER) - 🤔 STORED - Post count, not used in API responsesindexed_at
(TEXT) - ✅ USED - Cache timestampupdated_at
(TEXT) - ✅ USED - Update timestamp
Status: ✅ ACTIVE - Used for following feed functionality
follower_did
(TEXT, PRIMARY KEY) - ✅ USED - Follower DID, used in following queriesfollowing_did
(TEXT, PRIMARY KEY) - ✅ USED - Following DID, used in following queriescreated_at
(TEXT) - 🤔 STORED - Relationship creation time, not used in APIsynced_at
(TEXT) - ✅ USED - Last sync timestamp
Status: ❓ UNCLEAR - Defined in schema but usage uncertain
did
(TEXT, PRIMARY KEY) - ❓ UNKNOWN - User DIDhandle
(TEXT) - ❓ UNKNOWN - User handlepds
(TEXT) - ❓ UNKNOWN - PDS URLlast_checkin_crawl
(TEXT) - ❓ UNKNOWN - Last crawl timestamplast_follower_crawl
(TEXT) - ❓ UNKNOWN - Last follower crawladded_at
(TEXT) - ❓ UNKNOWN - Added timestampupdated_at
(TEXT) - ❓ UNKNOWN - Update timestamp
Status: ✅ ACTIVE - Used in stats API endpoint
id
(INTEGER, PRIMARY KEY) - ✅ USED - Record IDrun_at
(TEXT) - ✅ USED - Processing run timestampevents_processed
(INTEGER) - ✅ USED - Event counterrors
(INTEGER) - ✅ USED - Error countduration_ms
(INTEGER) - ✅ USED - Processing duration
Status: ❓ UNCLEAR - Table exists but usage uncertain in current API
did
(TEXT, PRIMARY KEY) - ❓ UNKNOWN - User DIDhandle
(TEXT) - ❓ UNKNOWN - User handlepds_url
(TEXT) - ❓ UNKNOWN - PDS URLaccess_token
(TEXT) - ❓ UNKNOWN - OAuth access tokenrefresh_token
(TEXT) - ❓ UNKNOWN - OAuth refresh tokendpop_private_key
(TEXT) - ❓ UNKNOWN - DPoP private keydpop_public_key
(TEXT) - ❓ UNKNOWN - DPoP public keysession_id
(TEXT) - ❓ UNKNOWN - Session cookie IDcreated_at
(INTEGER) - ❓ UNKNOWN - Creation timestampupdated_at
(INTEGER) - ❓ UNKNOWN - Update timestamp
Status: ❓ UNCLEAR - Table exists but usage uncertain
did
(TEXT, PRIMARY KEY) - ❓ UNKNOWN - User DIDdisplay_name
(TEXT) - ❓ UNKNOWN - Display nameupdated_at
(TEXT) - ❓ UNKNOWN - Update timestamp
checkins_v1
- ❌ LEGACY - Old version, still referenced in legacy code but main API usescheckins
address_cache_v1
- ❌ LEGACY - Old version, still used by address resolver but should migrate
user_pdses
- ✅ ACTIVE - CRITICAL PDS CRAWLER TABLE - Tracks PDS reference counting and crawling coordination
- checkins: 16/21 fields actively used
- profile_cache: 6/10 fields actively used
- user_follows: 3/4 fields actively used
- processing_log: All 5 fields used
- checkins:
category
,category_group
,category_icon
(not in API responses) - profile_cache:
description
,followers_count
,following_count
,posts_count
- user_follows:
created_at
- address_cache: Entire table usage unclear
- anchor_users: Entire table usage unclear
- oauth_sessions: Entire table usage unclear
- display_names: Entire table usage unclear
checkins_v1
address_cache_v1
user_pdses
- ✅ CRITICAL PDS crawler infrastructure
MAJOR FIELD NAME INCONSISTENCIES DISCOVERED - This likely explains the venue name issues!
-
Address fields in
checkins
table:- API code (
anchor-api.ts
) uses:addressStreet
,addressLocality
,addressRegion
, etc. - Backend code (
queries.ts
) uses:cached_address_street
,cached_address_locality
, etc. - Schema defines:
address_street
,address_locality
, etc.
- API code (
-
Author fields:
- API code uses:
did
,handle
- Legacy code uses:
author_did
,author_handle
- API code uses:
✅ CONFIRMED ACTIVE:
checkins
(new API format)checkins_v1
(legacy - universal-storage.ts, address-resolver.ts)profile_cache
(storage-provider.ts, queries.ts)address_cache_v1
(universal-storage.ts, address-resolver.ts)user_follows
(followers-processor.ts, API)anchor_users
(user-tracking.ts, followers-processor.ts)user_pdses
(user-tracking.ts - PDS crawler)oauth_sessions
(oauth/session.ts, oauth/dpop.ts, oauth/endpoints.ts)processing_log
(API stats)
❌ NOT FOUND IN ACTIVE CODE:
address_cache
(only in schema/migrations)display_names
(only in schema/migrations)
- ✅ Fixed field name inconsistencies - All code now uses consistent
venueName
field - ✅ Unified API queries - All endpoints use same Drizzle queries with consistent field names
- ✅ Removed duplicate endpoints - Eliminated
/api/feed
, consolidated to/api/global
- ✅ Cleaned up unused functions - Removed
getRecentCheckins()
after endpoint consolidation - ✅ Fixed TypeScript errors - Resolved Drizzle query builder issues preventing deployment
- ✅ Verified venue name resolution - Field name inconsistencies that caused venue name issues are resolved
- Database Schema: Fully migrated to Drizzle with type safety
- Field Names: All unified (
venueName
,addressStreet
, etc.) - API Endpoints: Single set serves both web and mobile clients
- Query Consistency: All feeds use same Drizzle queries and field names
- Deployment: Successfully deployed and tested at dropanchor.app
- ✅ Removed unused tables - Successfully dropped
address_cache
anddisplay_names
tables- Migration
007_remove_unused_tables
executed successfully - Verified removal via admin endpoint
/api/admin/check-unused-tables
- Migration
- Migrate legacy tables - Update remaining code to use current schemas instead of v1 tables
checkins_v1
: Still used by universal-storage.ts and address-resolver.tsaddress_cache_v1
: Still used by address resolver system
- Continue migration system - Current Drizzle migration approach is working well
All critical field name inconsistencies have been resolved. The venue name issues that prompted this audit are now fixed.