MCPcopy Create free account
hub / github.com/apache/devlake / ModifyColumnType

Method ModifyColumnType

backend/impls/dalgorm/dalgorm.go:376–391  ·  view source on GitHub ↗

ModifyColumnType modify column type

(table, columnName, columnType string)

Source from the content-addressed store, hash-verified

374
375// ModifyColumnType modify column type
376func (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
394func (d *Dalgorm) AllTables() ([]string, errors.Error) {

Callers

nothing calls this directly

Calls 2

ExecMethod · 0.95
NameMethod · 0.65

Tested by

no test coverage detected