RenameColumn renames column name for specified table
(table, oldColumnName, newColumnName string)
| 359 | |
| 360 | // RenameColumn renames column name for specified table |
| 361 | func (d *Dalgorm) RenameColumn(table, oldColumnName, newColumnName string) errors.Error { |
| 362 | // work around the error `cached plan must not change result type` for postgres |
| 363 | // wrap in func(){} to make the linter happy |
| 364 | defer func() { |
| 365 | _ = d.Exec("SELECT * FROM ? LIMIT 1", clause.Table{Name: table}) |
| 366 | }() |
| 367 | return d.Exec( |
| 368 | "ALTER TABLE ? RENAME COLUMN ? TO ?", |
| 369 | clause.Table{Name: table}, |
| 370 | clause.Column{Name: oldColumnName}, |
| 371 | clause.Column{Name: newColumnName}, |
| 372 | ) |
| 373 | } |
| 374 | |
| 375 | // ModifyColumnType modify column type |
| 376 | func (d *Dalgorm) ModifyColumnType(table, columnName, columnType string) errors.Error { |