Overview
TheWoodType model represents different types of wood available for furniture production. It includes an optional description field, audit trail, and soft delete support.
Table Name: wood_types
Fields
Primary Key
Unique identifier for the wood type. Auto-incremented primary key.
Core Fields
Name of the wood type (e.g., “Oak”, “Pine”, “Walnut”). Must be unique.Constraints:
- Maximum length: 100 characters
- Unique: true
- Nullable: false
Optional description providing additional details about the wood type.Constraints:
- Maximum length: 255 characters
- Nullable: true
Indicates whether the wood type is active in the system.Default:
trueAudit Trail Fields
Timestamp when the wood type was created.Default: Current timestamp (server-side)
Timestamp when the wood type was last updated. Automatically updated on record modification.Default: Current timestamp (server-side)On Update: Automatically set to current timestamp
Timestamp when the wood type was soft-deleted.
NULL if the record is not deleted.Username or identifier of the user who created the wood type.
Username or identifier of the user who last updated the wood type.
Username or identifier of the user who soft-deleted the wood type.
Methods
to_dict()
Serializes the WoodType model instance to a dictionary format. Returns:dict
The wood type’s unique identifier
The wood type name
Optional description of the wood type
Active status of the wood type
Creation timestamp
Last update timestamp
Soft delete timestamp (if applicable)
Model Source Code
Notes
- Unlike other models,
to_dict()returns raw timestamp objects instead of ISO formatted strings - The model includes an optional
descriptionfield for additional wood type details - Implements soft delete functionality via the
deleted_atfield - The
to_dict()method includes thedeleted_atfield in responses