dialect/sql: add rename-index to mysql builder (#300)

This commit is contained in:
Ariel Mashraki
2020-01-20 12:53:04 -05:00
committed by GitHub
parent 5cb40ff883
commit ba189b5f33
2 changed files with 10 additions and 0 deletions

View File

@@ -252,6 +252,12 @@ func (t *TableAlter) DropColumn(c *ColumnBuilder) *TableAlter {
return t
}
// RenameIndex appends the `RENAME INDEX` clause to the given `ALTER TABLE` statement.
func (t *TableAlter) RenameIndex(curr, new string) *TableAlter {
t.Queries = append(t.Queries, Raw(fmt.Sprintf("RENAME INDEX %s TO %s", t.Quote(curr), t.Quote(new))))
return t
}
// AddForeignKey adds a foreign key constraint to the `ALTER TABLE` statement.
func (t *TableAlter) AddForeignKey(fk *ForeignKeyBuilder) *TableAlter {
t.Queries = append(t.Queries, &Wrapper{"ADD CONSTRAINT %s", fk})