AddColumn add one column for the table
(table, columnName string, columnType dal.ColumnType)
| 325 | |
| 326 | // AddColumn add one column for the table |
| 327 | func (d *Dalgorm) AddColumn(table, columnName string, columnType dal.ColumnType) errors.Error { |
| 328 | // work around the error `cached plan must not change result type` for postgres |
| 329 | // wrap in func(){} to make the linter happy |
| 330 | defer func() { |
| 331 | _ = d.Exec("SELECT * FROM ? LIMIT 1", clause.Table{Name: table}) |
| 332 | }() |
| 333 | return d.Exec("ALTER TABLE ? ADD ? ?", clause.Table{Name: table}, clause.Column{Name: columnName}, clause.Expr{SQL: columnType.String()}) |
| 334 | } |
| 335 | |
| 336 | // DropColumns drop one column from the table |
| 337 | func (d *Dalgorm) DropColumns(table string, columnNames ...string) errors.Error { |