Indexes
Adds an index on the column.
index creates {table}_{column}_index, index:warehouse_id,status creates a composite index starting with the field column. Repeat the parameter for more indexes: index|index:status.Long index names are shortened automatically to fit the 64 character MySQL limit.Adds a unique index on the column.
unique_index:order_id creates a unique combination with another column. It can be combined with index on the same field.Adds the column into the fulltext index of the table. All fulltext fields share one index named
{table}_full_fulltext, which is rebuilt when the set of fulltext fields changes and dropped when no field has fulltext.Removing
index or unique_index from a field does not drop an existing index.Default value
default is used as the column default, prefilled in the create form and merged into API requests by Model::validator()->addDefaultValues().
- A
belongsTodefault only prefills the form, the column default staysNULL. - JSON columns (
multiple,locale) andencryptedfields get no database default, the value is still prefilled in the form and used byaddDefaultValues(). - In a model opened inside a parent record,
default:table.columnprefills the value of a column of the parent record, e.g.default:categories.name. It is used only in the form. - Date fields accept
default:CURRENT_TIMESTAMP.
Decimal precision
decimal_length sets the precision and the scale of a decimal column, decimal(8,2) by default. The step of the form input follows the scale.
decimal_length:10:3 is accepted as well.
Encrypted values
encrypted stores the value encrypted with the application key in a text column. The model returns the decrypted value.
- A cast type can be given as
encrypted:array,encrypted:collectionorencrypted:object.type:json|encryptedusesencrypted:array. - String, decimal and date fields stay searchable in the administration by the whole value (case insensitive), a part of the value is not found. The hashes for searching are stored in the
_encrypted_hashescolumn. - Adding
encryptedto a field does not encrypt the stored rows. Encrypt them withadmin:encrypt-existing.
Changing fields
php artisan admin:migrate compares the fields with the database and updates the table:
- a new field adds a column,
- changing
type,maxordefaultchanges the existing column, stored values are kept, - a removed field asks before its column is dropped, use
--auto-dropin deploy scripts to drop it without asking.
null) and unsigned columns (min:0, unsigned) are described in validation rules, fields without a column in field types.