diff --git a/sections/schema.js b/sections/schema.js index 8176442b..562c3f7e 100644 --- a/sections/schema.js +++ b/sections/schema.js @@ -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'); + }) + ` } ] },