You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define and implement the core Notification struct and its per-user database schema using GORM. This is the foundational data layer all other PBIs depend on — nothing else can be built until the model and schema are in place and reviewed.
User Story
As a backend engineer, I want a well-defined, GORM-annotated notification model persisted to the database, so that all other components in the notification system have a stable, tested data contract to build against.
Acceptance Criteria
Model defined: A Notification struct is created with all required fields: id (UUID), user_id, type (enum: alert, warning, info, success), title, message, host_id (nullable), record_id (nullable), correlation_id (nullable), actions (serialised JSON), meta (serialised as []map[string]string), is_read (bool, default false), created_at.
Action sub-type defined: An Action struct is created with fields: label, type (enum: navigate, api_call), target, method (nullable), payload (nullable map[string]string). Actions are stored as a JSON column on the notification row.
GORM annotations correct: All fields carry appropriate GORM tags. actions and meta are stored as serialised JSON columns. Indexes are defined on user_id, is_read, correlation_id, and created_at.
Auto-migrate verified: Running db.AutoMigrate against a fresh database produces the correct schema for both SQLite and PostgreSQL.
Type enum validated: The type field is validated against the allowed enum values on creation; invalid values return a descriptive error.
Unit tests: Tests cover model creation, JSON serialisation/deserialisation of actions and meta, and enum validation.
Definition of Done
Code implemented following best practices.
Unit tests written and passing.
Code reviewed and approved.
Merged into the main branch.
Documentation updated (if applicable).
Deployed to staging/production environment.
Assumptions and Constraints
Assumption: The project is using GORM as established in the database migration feature. This PBI builds directly on that foundation.
Constraint: actions and meta must survive a round-trip through both SQLite (TEXT column) and PostgreSQL (JSONB column) without data loss.
Description
Define and implement the core
Notificationstruct and its per-user database schema using GORM. This is the foundational data layer all other PBIs depend on — nothing else can be built until the model and schema are in place and reviewed.User Story
As a backend engineer, I want a well-defined, GORM-annotated notification model persisted to the database, so that all other components in the notification system have a stable, tested data contract to build against.
Acceptance Criteria
Notificationstruct is created with all required fields:id(UUID),user_id,type(enum:alert,warning,info,success),title,message,host_id(nullable),record_id(nullable),correlation_id(nullable),actions(serialised JSON),meta(serialised as[]map[string]string),is_read(bool, defaultfalse),created_at.Actionstruct is created with fields:label,type(enum:navigate,api_call),target,method(nullable),payload(nullablemap[string]string). Actions are stored as a JSON column on the notification row.actionsandmetaare stored as serialised JSON columns. Indexes are defined onuser_id,is_read,correlation_id, andcreated_at.db.AutoMigrateagainst a fresh database produces the correct schema for both SQLite and PostgreSQL.typefield is validated against the allowed enum values on creation; invalid values return a descriptive error.actionsandmeta, and enum validation.Definition of Done
Assumptions and Constraints
actionsandmetamust survive a round-trip through both SQLite (TEXT column) and PostgreSQL (JSONB column) without data loss.Dependencies
No response
Additional Notes
No response