Overview
TheColor model represents colors available in the furniture catalog. It includes validation, audit trail fields, and soft delete functionality.
Table Name: colors
Fields
Primary Key
Unique identifier for the color. Auto-incremented primary key.
Core Fields
Name of the color. Must be unique across all colors.Constraints:
- Maximum length: 50 characters
- Unique: true
- Nullable: false
Indicates whether the color is active in the system.Default:
trueAudit Trail Fields
Timestamp when the color was created.Default: Current timestamp (server-side)
Timestamp when the color was last updated. Automatically updated on record modification.Default: Current timestamp (server-side)On Update: Automatically set to current timestamp
Timestamp when the color was soft-deleted.
NULL if the record is not deleted.Username or identifier of the user who created the color.
Username or identifier of the user who last updated the color.
Username or identifier of the user who soft-deleted the color.
Methods
to_dict()
Serializes the Color model instance to a dictionary format suitable for JSON responses. Returns:dict
The color’s unique identifier
The color name
Active status of the color
ISO 8601 formatted creation timestamp
ISO 8601 formatted last update timestamp
Model Source Code
Notes
- The model implements soft delete functionality via the
deleted_atfield - Timestamps are managed automatically by the database
- The
to_dict()method excludes soft-delete audit fields from the response - All audit trail
*_byfields accept up to 100 characters for user identification