1
0
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:
Simon Vieille 2022-07-29 14:57:18 +02:00 committed by GitHub
parent b9e1de33c5
commit 6351684070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -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
}

View 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
},
}

View File

@ -33,6 +33,7 @@ var migrationTasks = []*task{
&fixPRSecretEventName,
&alterTableReposDropCounter,
&dropSenders,
&alterTableLogUpdateColumnLogDataType,
}
var allBeans = []interface{}{