kysely
kysely copied to clipboard
Add `CREATE TABLE ... LIKE ...` syntax
CREATE TABLE newTableName LIKE templateTableName allows creating the table with the same structure as an already existing one, and is especially useful when creating temporary tables.
It is supported by PostgreSQL and MySQL.
I suggest the following syntax:
await db.createTable("newTable")
.like("oldTable")
.including("INDEXES"); // Only for PostgreSQL.
.including("COMMENTS") // User may specify multiple including statements, maybe we should use accept array as parameter instead?
.excluding("DEFAULTS") // Excluding is the default, but can be useful with `.including("ALL")`.
// ...
I may look into implementing that, if that feature would be accepted into the project. Thanks in advance!