@@ -13,9 +13,9 @@ import (
1313 "github.com/stretchr/testify/assert"
1414)
1515
16- func Test_FixReviewStateUpdatedFilesColumn (t * testing.T ) {
17- if setting .Database .Type == "sqlite3" {
18- t .Skip ("SQLite does not support modify column type " )
16+ func Test_UseLongTextInSomeColumnsAndFixBugs (t * testing.T ) {
17+ if ! setting .Database .Type . IsMySQL () {
18+ t .Skip ("Only MySQL needs to change from TEXT to LONGTEXT " )
1919 }
2020
2121 type ReviewState struct {
@@ -27,16 +27,45 @@ func Test_FixReviewStateUpdatedFilesColumn(t *testing.T) {
2727 UpdatedUnix timeutil.TimeStamp `xorm:"updated"` // Is an accurate indicator of the order of commits as we do not expect it to be possible to make reviews on previous commits
2828 }
2929
30+ type PackageProperty struct {
31+ ID int64 `xorm:"pk autoincr"`
32+ RefType int `xorm:"INDEX NOT NULL"`
33+ RefID int64 `xorm:"INDEX NOT NULL"`
34+ Name string `xorm:"INDEX NOT NULL"`
35+ Value string `xorm:"TEXT NOT NULL"`
36+ }
37+
38+ type Notice struct {
39+ ID int64 `xorm:"pk autoincr"`
40+ Type int
41+ Description string `xorm:"LONGTEXT"`
42+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
43+ }
44+
3045 // Prepare and load the testing database
31- x , deferable := base .PrepareTestEnv (t , 0 , new (ReviewState ))
46+ x , deferable := base .PrepareTestEnv (t , 0 , new (ReviewState ), new ( PackageProperty ), new ( Notice ) )
3247 defer deferable ()
3348
34- assert .NoError (t , FixReviewStateUpdatedFilesColumn (x ))
49+ assert .NoError (t , UseLongTextInSomeColumnsAndFixBugs (x ))
3550
3651 tableInfo , err := x .TableInfo (& ReviewState {})
3752 assert .NoError (t , err )
3853 assert .NotNil (t , tableInfo )
3954 column := tableInfo .GetColumn ("updated_files" )
4055 assert .NotNil (t , column )
4156 assert .Equal (t , "LONGTEXT" , column .SQLType .Name )
57+
58+ tableInfo , err = x .TableInfo (& PackageProperty {})
59+ assert .NoError (t , err )
60+ assert .NotNil (t , tableInfo )
61+ column = tableInfo .GetColumn ("value" )
62+ assert .NotNil (t , column )
63+ assert .Equal (t , "LONGTEXT" , column .SQLType .Name )
64+
65+ tableInfo , err = x .TableInfo (& Notice {})
66+ assert .NoError (t , err )
67+ assert .NotNil (t , tableInfo )
68+ column = tableInfo .GetColumn ("description" )
69+ assert .NotNil (t , column )
70+ assert .Equal (t , "LONGTEXT" , column .SQLType .Name )
4271}
0 commit comments