Skip to content

Commit

Permalink
add jsdoc & examples @ AlterTableBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaspero committed Nov 7, 2023
1 parent 7bdea61 commit ea88a77
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/schema/alter-table-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,25 @@ export class AlterTableBuilder implements ColumnAlteringInterface {
})
}

/**
* This can be used to add index to table.
*
* ### Examples
*
* ```ts
* db.schema.alterTable('person')
* .addIndex('person_email_index')
* .column('email')
* .unique()
* .execute()
* ```
*
* The generated SQL (MySQL):
*
* ```sql
* alter table `person` add unique index `person_email_index` (`email`)
* ```
*/
addIndex(indexName: string): AlterTableAddIndexBuilder {
return new AlterTableAddIndexBuilder({
...this.#props,
Expand All @@ -251,6 +270,23 @@ export class AlterTableBuilder implements ColumnAlteringInterface {
})
}

/**
* This can be used to drop index from table.
*
* ### Examples
*
* ```ts
* db.schema.alterTable('person')
* .dropIndex('person_email_index')
* .execute()
* ```
*
* The generated SQL (MySQL):
*
* ```sql
* alter table `person` drop index `test_first_name_index`
* ```
*/
dropIndex(indexName: string): AlterTableExecutor {
return new AlterTableExecutor({
...this.#props,
Expand Down

0 comments on commit ea88a77

Please sign in to comment.