Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for additional enum options #117

Merged
merged 2 commits into from Jul 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions sections/schema.js
Expand Up @@ -220,7 +220,7 @@ export default [
method: "increments",
example: "table.increments(name)",
description: "Adds an auto incrementing column. In PostgreSQL this is a serial; in Amazon Redshift an integer identity(1,1). This will be used as the primary key for the table. Also available is a bigIncrements if you wish to add a bigint incrementing number (in PostgreSQL bigserial).",
children: [
children: [
{
type: 'code',
language: 'js',
Expand All @@ -240,7 +240,7 @@ export default [
table.foreign('author').references('userId').inTable('users');
});
`
}
}
]
},
{
Expand Down Expand Up @@ -349,12 +349,26 @@ export default [
type: "method",
id: "Schema-enum",
method: "enum / enu",
example: "table.enu(col, values)",
example: "table.enu(col, values, [options])",
description: "Adds a enum column, (aliased to enu, as enum is a reserved word in JavaScript). Implemented as unchecked varchar(255) on Amazon Redshift. Note that the second argument is an array of values. Example:",
children: [{
type: 'code',
language: 'js',
content: `table.enu('column', ['value1', 'value2'])`
}, {
type: 'text',
content: "For Postgres, an additional options argument can be provided to specify whether or not to use Postgres's native TYPE:"
}, {
type: 'code',
language: 'js',
content: `table.enu('column', ['value1', 'value2'], { useNative: true, enumName: 'foo_type' })`
}, {
type: 'text',
content: "It will use the values provided to generate the appropriate TYPE. Example:"
}, {
type: 'code',
language: 'sql',
content: `CREATE TYPE "foo_type" AS ENUM ('value1', 'value2');`
}]
},
{
Expand Down