gitea源码

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_25
  4. import (
  5. "code.gitea.io/gitea/models/migrations/base"
  6. "code.gitea.io/gitea/modules/setting"
  7. "xorm.io/xorm"
  8. "xorm.io/xorm/schemas"
  9. )
  10. func UseLongTextInSomeColumnsAndFixBugs(x *xorm.Engine) error {
  11. if !setting.Database.Type.IsMySQL() {
  12. return nil // Only mysql need to change from text to long text, for other databases, they are the same
  13. }
  14. if err := base.ModifyColumn(x, "review_state", &schemas.Column{
  15. Name: "updated_files",
  16. SQLType: schemas.SQLType{
  17. Name: "LONGTEXT",
  18. },
  19. Length: 0,
  20. Nullable: false,
  21. DefaultIsEmpty: true,
  22. }); err != nil {
  23. return err
  24. }
  25. if err := base.ModifyColumn(x, "package_property", &schemas.Column{
  26. Name: "value",
  27. SQLType: schemas.SQLType{
  28. Name: "LONGTEXT",
  29. },
  30. Length: 0,
  31. Nullable: false,
  32. DefaultIsEmpty: true,
  33. }); err != nil {
  34. return err
  35. }
  36. return base.ModifyColumn(x, "notice", &schemas.Column{
  37. Name: "description",
  38. SQLType: schemas.SQLType{
  39. Name: "LONGTEXT",
  40. },
  41. Length: 0,
  42. Nullable: false,
  43. DefaultIsEmpty: true,
  44. })
  45. }