Skip to content

Command Line Tools

wheels generate property

Add properties to existing model files with database migrations and view updates.

Terminal window
wheels generate property name=<modelName> columnName=<propertyName> [options]
#Can also be used as:
wheels g property name=<modelName> columnName=<propertyName> [options]

CommandBox supports multiple parameter formats:

  • Named parameters: name=value (e.g., name=User, columnName=email)
  • Flag parameters: --flag equals flag=true (e.g., --allowNull equals allowNull=true)
  • Flag with value: --flag=value equals flag=value (e.g., --dataType=boolean)

Note: Flag syntax (--flag) avoids positional/named parameter conflicts and is recommended for boolean options.

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.

ArgumentDescriptionDefault
nameModel name (table name)Required
columnNameName of column to addRequired
OptionDescriptionValid ValuesDefault
dataTypeType of columnbiginteger, binary, boolean, date, datetime, decimal, float, integer, string, text, time, timestamp, uuidstring
defaultDefault value for columnAny valid default value""
allowNullWhether to allow null valuestrue, falsetrue
limitCharacter or integer size limitNumeric value0
precisionPrecision for decimal columnsNumeric value0
scaleScale for decimal columnsNumeric value0
TypeDatabase TypeDescription
bigintegerBIGINTLarge integer values
binaryBLOBBinary data
booleanBOOLEANBoolean (true/false) values
dateDATEDate only
datetimeDATETIMEDate and time
decimalDECIMALDecimal numbers with precision/scale
floatFLOATFloating point numbers
integerINTEGERInteger values
stringVARCHARVariable character strings
textTEXTLong text content
timeTIMETime only
timestampTIMESTAMPTimestamp values
uuidVARCHAR(35)UUID/GUID strings
Terminal window
wheels generate property name=User columnName=firstName

Creates a string property called firstName on the User model.

Terminal window
wheels generate property name=User columnName=isActive --dataType=boolean --default=0

Creates a boolean property with default value of 0 (false).

Terminal window
wheels generate property name=User columnName=lastLoggedIn --dataType=datetime

Creates a datetime property on the User model.

Terminal window
wheels generate property name=Product columnName=price --dataType=decimal --precision=10 --scale=2

Creates a decimal property with 10 total digits and 2 decimal places.

Terminal window
wheels generate property name=User columnName=username --dataType=string --limit=50 --allowNull=false

Creates a required string property with maximum 50 characters.

  1. Creates Database Migration: Generates a migration file to add the column to the database
  2. Updates Form View: Adds the property to _form.cfm if it exists
  3. Updates Index View: Adds the property to index.cfm table if it exists
  4. Updates Show View: Adds the property to show.cfm if it exists
  5. Offers Migration: Prompts to run the migration immediately

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");
}
}
}

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>
  1. Run migrations immediately when prompted
  2. Use semantic property names (firstName, not fname)
  3. Set appropriate defaults for boolean and numeric fields
  4. Consider null constraints based on business logic
  5. Add one property at a time for better change tracking