Skip to content

Commit

Permalink
Add callback doc for create table like (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierCavadenti committed Nov 10, 2021
1 parent 3560252 commit 48fcde1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sections/schema.js
Expand Up @@ -46,14 +46,24 @@ export default [
{
type: "method",
method: "createTableLike",
example: "knex.schema.createTableLike(tableName, tableNameToCopy)",
description: "Creates a new table on the database based on another table. Copy only the structure : columns, keys and indexes (expected on SQL Server which only copy columns) and not the data.",
example: "knex.schema.createTableLike(tableName, tableNameToCopy, [callback])",
description: "Creates a new table on the database based on another table. Copy only the structure : columns, keys and indexes (expected on SQL Server which only copy columns) and not the data. Callback function can be specified to add columns in the duplicated table.",
children: [
{
type: "runnable",
content: `
knex.schema.createTableLike('new_users', 'users')
`
},
{
type: "runnable",
content: `
// "new_users" table contains columns of users and two new columns 'age' and 'last_name'.
knex.schema.createTableLike('new_users', 'users', (table) => {
table.integer('age');
table.string('last_name');
})
`
}
]
},
Expand Down

0 comments on commit 48fcde1

Please sign in to comment.