-
Notifications
You must be signed in to change notification settings - Fork 1
Data Types & Options
Branden Horiuchi edited this page Jul 7, 2015
·
4 revisions
Data types are taken directly from knex.js Please familiarize yourself with valid combinations of types and options as knex-schemer will not validate the schema supplied to it.
When specifying a type the parameter type: <data type> should be specified along with any additional options and their values
<tr>
<td>integer</td>
<td>unassigned: [true | false]</td>
</tr>
<tr>
<td>bigInteger</td>
<td></td>
</tr>
<tr>
<td>string</td>
<td>size: <integer></td>
</tr>
<tr>
<td>text</td>
<td>textType: [text | mediumtext | longtext]</td>
</tr>
<tr>
<td>float</td>
<td>
precision: <integer>
<br>
scale: <integer>
</td>
</tr>
<tr>
<td>decimal</td>
<td>
precision: <integer>
<br>
scale: <integer>
</td>
</tr>
<tr>
<td>boolean</td>
<td></td>
</tr>
<tr>
<td>date</td>
<td></td>
</tr>
<tr>
<td>dateTime</td>
<td></td>
</tr>
<tr>
<td>time</td>
<td></td>
</tr>
<tr>
<td>timestamp</td>
<td>standard: <a timestamp standard></td>
</tr>
<tr>
<td>binary</td>
<td>length: <integer></td>
</tr>
<tr>
<td>json</td>
<td>jsonb: [true | false]</td>
</tr>
<tr>
<td>uuid</td>
<td></td>
</tr>
| type | options |
|---|
<tr>
<td>index</td>
<td>true | false</td>
<td>
indexName: <index name>
<br>
indexType: <index type>
</td>
</tr>
<tr>
<td>primary</td>
<td>true | false</td>
<td></td>
</tr>
<tr>
<td>unique</td>
<td>true | false</td>
<td></td>
</tr>
<tr>
<td>references</td>
<td>column</td>
<td></td>
</tr>
<tr>
<td>inTable</td>
<td>table</td>
<td></td>
</tr>
<tr>
<td>onDelete</td>
<td>command</td>
<td></td>
</tr>
<tr>
<td>onUpdate</td>
<td>command</td>
<td></td>
</tr>
<tr>
<td>defaultTo</td>
<td>default value</td>
<td></td>
</tr>
<tr>
<td>nullable</td>
<td>true | false</td>
<td></td>
</tr>
<tr>
<td>first</td>
<td>true | false</td>
<td></td>
</tr>
<tr>
<td>after</td>
<td>column</td>
<td></td>
</tr>
<tr>
<td>comment</td>
<td>comment</td>
<td></td>
</tr>
| option | values | sub-option |
|---|
// the id field has a type of integer and 2 additional options
// set for auto-increment and primary key
// the name field is type string with a size option set to
// 50 which means the maximum length of text that the name
// column will hold is 50 characters
var schema = {
user: {
id: {type: 'integer', primary: true, increments: true},
name: {type: 'string', size: 50}
}
};See Ignoring
knex-schemer