import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { AlterTableBuilder } = kysely;
This builder can be used to create a alter table
query.
Constructors
Methods
Calls the given function passing this
as the only argument.
See CreateTableBuilder.$call
See CreateTableBuilder.addCheckConstraint
See CreateTableBuilder.addForeignKeyConstraint
Unlike CreateTableBuilder.addForeignKeyConstraint this method returns
the constraint builder and doesn't take a callback as the last argument. This
is because you can only add one column per ALTER TABLE
query.
This can be used to add index to table.
Examples
db.schema.alterTable('person')
.addIndex('person_email_index')
.column('email')
.unique()
.execute()
The generated SQL (MySQL):
alter table `person` add unique index `person_email_index` (`email`)
See CreateTableBuilder.addPrimaryKeyConstraint
See CreateTableBuilder.addUniqueConstraint
This can be used to drop index from table.
Examples
db.schema.alterTable('person')
.dropIndex('person_email_index')
.execute()
The generated SQL (MySQL):
alter table `person` drop index `test_first_name_index`
Creates an alter table modify column
query. The modify column
statement
is only implemeted by MySQL and oracle AFAIK. On other databases you
should use the alterColumn
method.