Skip to content
jordanclark edited this page Mar 28, 2013 · 1 revision

Usage

Adds a primary key definition to the table. this method also allows for multiple primary keys

Function Syntax

t.primaryKey(name,[,type,autoIncrement,limit,precision,scale,references,onUpdate,onDelete]);

Parameters

Parameter Type Required Default Description
name string Yes primary key column name
type string No integer type of column, allowed types include primaryKey, [binary](apitabledefinitionbinary), [boolean](apitabledefinitionboolean), [date](apitabledefinitiondate), [datetime](apitabledefinitiondatetime), [decimal](apitabledefinitiondecimal), [float](apitabledefinitionfloat.md), [integer](apitabledefinitioninteger), [string](apitabledefinitionstring), [text](apitabledefinitiontext), [time](apitabledefinitiontime), [timestamp](apitabledefinitiontimestamp)
autoIncrement boolean No false
limit integer No character or integer size limit for column
precision integer No precision value for decimal columns, i.e. number of digits the column can hold
scale integer No scale value for decimal columns, i.e. number of digits that can be placed to the right of the decimal point (must be less than or equal to precision)
references string No table this primary key should reference as a foreign key
onUpdate string No how you want the constraint to act on update. possible values include `none`, `null`, or `cascade` which can also be set to `true`.
onDelete string No how you want the constraint to act on delete. possible values include `none`, `null`, or `cascade` which can also be set to `true`.

Notes

Examples

Clone this wiki locally