Audo add ID - Causing error in Creating Chat Session · Pull Request #1 · harshhh28/hia (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an error in creating chat sessions by adding auto-generated UUID defaults to primary key columns. The change ensures that UUID primary keys are automatically generated when new records are inserted, eliminating the need for manual ID specification.
- Added
DEFAULT gen_random_uuid()to UUID primary key columns in three tables - Resolves issues where applications might not provide ID values during record creation
| -- Create users table |
|---|
| CREATE TABLE users ( |
| id UUID PRIMARY KEY, |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using a more deterministic UUID generation function like uuid_generate_v4() from the uuid-ossp extension instead of gen_random_uuid(). While gen_random_uuid() is available in PostgreSQL 13+, uuid_generate_v4() is more widely supported and follows UUID v4 standards more explicitly.
Copilot uses AI. Check for mistakes.