mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Update type of 'log_data' from blob to longblob (#1050)
* Update type of 'log_data' from blob to longblob * Add migration task to update log_data type
This commit is contained in:
parent
b9e1de33c5
commit
6351684070
@ -17,6 +17,6 @@ package model
|
||||
type Logs struct {
|
||||
ID int64 `xorm:"pk autoincr 'log_id'"`
|
||||
ProcID int64 `xorm:"UNIQUE 'log_job_id'"`
|
||||
Data []byte `xorm:"log_data"`
|
||||
Data []byte `xorm:"LONGBLOB 'log_data'"`
|
||||
// TODO: add create timestamp
|
||||
}
|
||||
|
27
server/store/datastore/migration/006_log_data_type.go
Normal file
27
server/store/datastore/migration/006_log_data_type.go
Normal file
@ -0,0 +1,27 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
var alterTableLogUpdateColumnLogDataType = task{
|
||||
name: "alter-table-logs-update-type-of-data",
|
||||
fn: func(sess *xorm.Session) (err error) {
|
||||
dialect := sess.Engine().Dialect().URI().DBType
|
||||
|
||||
switch dialect {
|
||||
case schemas.POSTGRES:
|
||||
_, err = sess.Exec("ALTER TABLE logs ALTER COLUMN log_data TYPE BYTEA")
|
||||
case schemas.MYSQL:
|
||||
_, err = sess.Exec("ALTER TABLE logs MODIFY COLUMN log_data LONGBLOB")
|
||||
case schemas.MSSQL:
|
||||
_, err = sess.Exec("ALTER TABLE logs MODIFY COLUMN log_data VARBINARY")
|
||||
default:
|
||||
// sqlite does only know BLOB in all cases
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
},
|
||||
}
|
@ -33,6 +33,7 @@ var migrationTasks = []*task{
|
||||
&fixPRSecretEventName,
|
||||
&alterTableReposDropCounter,
|
||||
&dropSenders,
|
||||
&alterTableLogUpdateColumnLogDataType,
|
||||
}
|
||||
|
||||
var allBeans = []interface{}{
|
||||
|
Loading…
Reference in New Issue
Block a user