From cc62c738f0bdfd62fc9d07cacba28986e13621f1 Mon Sep 17 00:00:00 2001 From: Olivier Cavadenti Date: Wed, 10 Nov 2021 21:06:21 +0100 Subject: [PATCH 1/2] Add callback doc for create table like --- sections/schema.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sections/schema.js b/sections/schema.js index 8176442b..531b7b80 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', function(table){ + table.integer('age'); + table.string('last_name'); + }) + ` } ] }, From e36d84357b71798268f3764be36dadd78e5cf2be Mon Sep 17 00:00:00 2001 From: Olivier Cavadenti Date: Wed, 10 Nov 2021 21:10:24 +0100 Subject: [PATCH 2/2] pr returns --- sections/schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sections/schema.js b/sections/schema.js index 531b7b80..562c3f7e 100644 --- a/sections/schema.js +++ b/sections/schema.js @@ -46,7 +46,7 @@ export default [ { type: "method", method: "createTableLike", - example: "knex.schema.createTableLike(tableName, tableNameToCopy, callback)", + 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: [ { @@ -59,7 +59,7 @@ export default [ type: "runnable", content: ` // "new_users" table contains columns of users and two new columns 'age' and 'last_name'. - knex.schema.createTableLike('new_users', 'users', function(table){ + knex.schema.createTableLike('new_users', 'users', (table) => { table.integer('age'); table.string('last_name'); })