Command Line Tools
wheels generate property
wheels generate property
Section titled “wheels generate property”Add properties to existing model files with database migrations and view updates.
Synopsis
Section titled “Synopsis”wheels generate property name=<modelName> columnName=<propertyName> [options]
#Can also be used as:wheels g property name=<modelName> columnName=<propertyName> [options]Parameter Syntax
Section titled “Parameter Syntax”CommandBox supports multiple parameter formats:
- Named parameters:
name=value(e.g.,name=User,columnName=email) - Flag parameters:
--flagequalsflag=true(e.g.,--allowNullequalsallowNull=true) - Flag with value:
--flag=valueequalsflag=value(e.g.,--dataType=boolean)
Note: Flag syntax (--flag) avoids positional/named parameter conflicts and is recommended for boolean options.
Description
Section titled “Description”The wheels generate property command generates a database migration to add a property to an existing model and scaffolds it into _form.cfm and show.cfm views.
Arguments
Section titled “Arguments”| Argument | Description | Default |
|---|---|---|
name | Model name (table name) | Required |
columnName | Name of column to add | Required |
Options
Section titled “Options”| Option | Description | Valid Values | Default |
|---|---|---|---|
dataType | Type of column | biginteger, binary, boolean, date, datetime, decimal, float, integer, string, text, time, timestamp, uuid | string |
default | Default value for column | Any valid default value | "" |
allowNull | Whether to allow null values | true, false | true |
limit | Character or integer size limit | Numeric value | 0 |
precision | Precision for decimal columns | Numeric value | 0 |
scale | Scale for decimal columns | Numeric value | 0 |
Data Type Options
Section titled “Data Type Options”| Type | Database Type | Description |
|---|---|---|
biginteger | BIGINT | Large integer values |
binary | BLOB | Binary data |
boolean | BOOLEAN | Boolean (true/false) values |
date | DATE | Date only |
datetime | DATETIME | Date and time |
decimal | DECIMAL | Decimal numbers with precision/scale |
float | FLOAT | Floating point numbers |
integer | INTEGER | Integer values |
string | VARCHAR | Variable character strings |
text | TEXT | Long text content |
time | TIME | Time only |
timestamp | TIMESTAMP | Timestamp values |
uuid | VARCHAR(35) | UUID/GUID strings |
Examples
Section titled “Examples”Basic string property
Section titled “Basic string property”wheels generate property name=User columnName=firstNameCreates a string property called firstName on the User model.
Boolean property with default
Section titled “Boolean property with default”wheels generate property name=User columnName=isActive --dataType=boolean --default=0Creates a boolean property with default value of 0 (false).
Datetime property
Section titled “Datetime property”wheels generate property name=User columnName=lastLoggedIn --dataType=datetimeCreates a datetime property on the User model.
Decimal property with precision
Section titled “Decimal property with precision”wheels generate property name=Product columnName=price --dataType=decimal --precision=10 --scale=2Creates a decimal property with 10 total digits and 2 decimal places.
String with character limit
Section titled “String with character limit”wheels generate property name=User columnName=username --dataType=string --limit=50 --allowNull=falseCreates a required string property with maximum 50 characters.
What the Command Does
Section titled “What the Command Does”- Creates Database Migration: Generates a migration file to add the column to the database
- Updates Form View: Adds the property to
_form.cfmif it exists - Updates Index View: Adds the property to
index.cfmtable if it exists - Updates Show View: Adds the property to
show.cfmif it exists - Offers Migration: Prompts to run the migration immediately
Generated Files
Section titled “Generated Files”Database Migration
Section titled “Database Migration”File: app/migrator/migrations/[timestamp]_create_column__[tableName]_[columnName].cfc
component extends="wheels.migrator.Migration" {
function up() { transaction { addColumn( table = "users", columnName = "firstName", columnType = "string", limit = 255, allowNull = true ); } }
function down() { transaction { removeColumn(table = "users", columnName = "firstName"); } }}View Updates
Section titled “View Updates”When views exist, the command adds the new property:
Form View: Adds appropriate input field
#textField(objectName="user", property="firstName")#Index View: Adds column to table
<th>First Name</th><td>#user.firstName#</td>Show View: Adds property display
<p><strong>First Name:</strong> #user.firstName#</p>Best Practices
Section titled “Best Practices”- Run migrations immediately when prompted
- Use semantic property names (firstName, not fname)
- Set appropriate defaults for boolean and numeric fields
- Consider null constraints based on business logic
- Add one property at a time for better change tracking
See Also
Section titled “See Also”- wheels generate model - Generate models
- wheels dbmigrate create column - Create columns
- wheels generate test - Generate tests