ModifyColumnType modify column type
(table, columnName, columnType string)
| 374 | |
| 375 | // ModifyColumnType modify column type |
| 376 | func (d *Dalgorm) ModifyColumnType(table, columnName, columnType string) errors.Error { |
| 377 | // work around the error `cached plan must not change result type` for postgres |
| 378 | // wrap in func(){} to make the linter happy |
| 379 | defer func() { |
| 380 | _ = d.Exec("SELECT * FROM ? LIMIT 1", clause.Table{Name: table}) |
| 381 | }() |
| 382 | query := "ALTER TABLE ? MODIFY COLUMN ? %s" |
| 383 | if d.db.Dialector.Name() == "postgres" { |
| 384 | query = "ALTER TABLE ? ALTER COLUMN ? TYPE %s" |
| 385 | } |
| 386 | return d.Exec( |
| 387 | fmt.Sprintf(query, columnType), |
| 388 | clause.Table{Name: table}, |
| 389 | clause.Column{Name: columnName}, |
| 390 | ) |
| 391 | } |
| 392 | |
| 393 | // AllTables returns all tables in the database |
| 394 | func (d *Dalgorm) AllTables() ([]string, errors.Error) { |