-
Notifications
You must be signed in to change notification settings - Fork 19
primaryKey
jordanclark edited this page Mar 28, 2013
·
1 revision
Adds a primary key definition to the table. this method also allows for multiple primary keys
t.primaryKey(name,[,type,autoIncrement,limit,precision,scale,references,onUpdate,onDelete]);
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`. |