feat/db-rework #3

Merged
jd merged 2 commits from feat/db-rework into feat/indexer 2026-01-20 01:43:49 +00:00
Owner
No description provided.
jd added 2 commits 2026-01-20 01:43:42 +00:00
This is a comprehensive refactoring that replaces UUID identifiers with auto-incrementing
`bigserial` primary keys across all database tables and associated Go code. The migration
includes schema changes, generated sqlc code updates, and corresponding application code
modifications.

Key changes:
- Schema: Changed all UUID PRIMARY KEY columns to BIGSERIAL PRIMARY KEY NOT NULL
- Schema: Added urlHash UUID column to Pages table for unique URL identification
- Models: Updated all struct types to use int64 instead of uuid.UUID for IDs
- New Types: Added dbtypes.NilInt64 for handling nullable bigserial references
- Generated Code: Added SQL query documentation comments via sqlc emit_sql_as_comment
- Application: Updated all database access functions to use int64 identifiers
- Cache Layer: Replaced UUID bytes with int64 binary encoding for groupcache keys
- Build: Removed github.com/google/uuid dependency from affected packages
This comprehensive refactor introduces several significant database and application changes:

- Migrated from BIGSERIAL to BIGINT GENERATED ALWAYS AS IDENTITY for modern PostgreSQL identity columns
- Added domainHash UUID column for efficient O(1) domain lookups replacing string-based searches
- Replaced separate state/status columns with single PageStates lookup table containing 12 predefined state combinations
- Added computed score column for simplified page ranking queries
- Updated all SQL queries and Go models to use hash-based lookups
- Added uuidhash package using Blake2b for consistent 16-byte hash generation
- Changed sqlc configuration to emit pointer structs for better null handling
- Added manual InsertPageFast implementation with upsert logic using temporary tables

BREAKING CHANGE: Database schema requires migration. Domain lookups now use domainHash UUID instead of domain string. Page state tracking changed from separate state/status columns to single PageStatus reference. All client code must update to use new hash-based APIs.
jd merged commit c50cc82ccd into feat/indexer 2026-01-20 01:43:49 +00:00
jd referenced this pull request from a commit 2026-01-20 01:43:49 +00:00
jd deleted branch feat/db-rework 2026-01-20 01:43:54 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Aletis/aletis!3
No description provided.