You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrations.go 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "bytes"
  7. "encoding/json"
  8. "fmt"
  9. "io/ioutil"
  10. "os"
  11. "path"
  12. "path/filepath"
  13. "strings"
  14. "time"
  15. "github.com/Unknwon/com"
  16. "github.com/go-xorm/xorm"
  17. gouuid "github.com/satori/go.uuid"
  18. "gopkg.in/ini.v1"
  19. "github.com/gogits/gogs/modules/base"
  20. "github.com/gogits/gogs/modules/log"
  21. "github.com/gogits/gogs/modules/setting"
  22. )
  23. const _MIN_DB_VER = 4
  24. type Migration interface {
  25. Description() string
  26. Migrate(*xorm.Engine) error
  27. }
  28. type migration struct {
  29. description string
  30. migrate func(*xorm.Engine) error
  31. }
  32. func NewMigration(desc string, fn func(*xorm.Engine) error) Migration {
  33. return &migration{desc, fn}
  34. }
  35. func (m *migration) Description() string {
  36. return m.description
  37. }
  38. func (m *migration) Migrate(x *xorm.Engine) error {
  39. return m.migrate(x)
  40. }
  41. // The version table. Should have only one row with id==1
  42. type Version struct {
  43. ID int64 `xorm:"pk autoincr"`
  44. Version int64
  45. }
  46. // This is a sequence of migrations. Add new migrations to the bottom of the list.
  47. // If you want to "retire" a migration, remove it from the top of the list and
  48. // update _MIN_VER_DB accordingly
  49. var migrations = []Migration{
  50. NewMigration("fix locale file load panic", fixLocaleFileLoadPanic), // V4 -> V5:v0.6.0
  51. NewMigration("trim action compare URL prefix", trimCommitActionAppUrlPrefix), // V5 -> V6:v0.6.3
  52. NewMigration("generate issue-label from issue", issueToIssueLabel), // V6 -> V7:v0.6.4
  53. NewMigration("refactor attachment table", attachmentRefactor), // V7 -> V8:v0.6.4
  54. NewMigration("rename pull request fields", renamePullRequestFields), // V8 -> V9:v0.6.16
  55. NewMigration("clean up migrate repo info", cleanUpMigrateRepoInfo), // V9 -> V10:v0.6.20
  56. NewMigration("generate rands and salt for organizations", generateOrgRandsAndSalt), // V10 -> V11:v0.8.5
  57. NewMigration("convert date to unix timestamp", convertDateToUnix), // V11 -> V12:v0.9.2
  58. NewMigration("convert LDAP UseSSL option to SecurityProtocol", ldapUseSSLToSecurityProtocol), // V12 -> V13:v0.9.37
  59. // v13 -> v14:v0.9.87
  60. NewMigration("set comment updated with created", setCommentUpdatedWithCreated),
  61. }
  62. // Migrate database to current version
  63. func Migrate(x *xorm.Engine) error {
  64. if err := x.Sync(new(Version)); err != nil {
  65. return fmt.Errorf("sync: %v", err)
  66. }
  67. currentVersion := &Version{ID: 1}
  68. has, err := x.Get(currentVersion)
  69. if err != nil {
  70. return fmt.Errorf("get: %v", err)
  71. } else if !has {
  72. // If the version record does not exist we think
  73. // it is a fresh installation and we can skip all migrations.
  74. currentVersion.Version = int64(_MIN_DB_VER + len(migrations))
  75. if _, err = x.InsertOne(currentVersion); err != nil {
  76. return fmt.Errorf("insert: %v", err)
  77. }
  78. }
  79. v := currentVersion.Version
  80. if _MIN_DB_VER > v {
  81. log.Fatal(4, `Gogs no longer supports auto-migration from your previously installed version.
  82. Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to current version.`)
  83. return nil
  84. }
  85. if int(v-_MIN_DB_VER) > len(migrations) {
  86. // User downgraded Gogs.
  87. currentVersion.Version = int64(len(migrations) + _MIN_DB_VER)
  88. _, err = x.Id(1).Update(currentVersion)
  89. return err
  90. }
  91. for i, m := range migrations[v-_MIN_DB_VER:] {
  92. log.Info("Migration: %s", m.Description())
  93. if err = m.Migrate(x); err != nil {
  94. return fmt.Errorf("do migrate: %v", err)
  95. }
  96. currentVersion.Version = v + int64(i) + 1
  97. if _, err = x.Id(1).Update(currentVersion); err != nil {
  98. return err
  99. }
  100. }
  101. return nil
  102. }
  103. func sessionRelease(sess *xorm.Session) {
  104. if !sess.IsCommitedOrRollbacked {
  105. sess.Rollback()
  106. }
  107. sess.Close()
  108. }
  109. func fixLocaleFileLoadPanic(_ *xorm.Engine) error {
  110. cfg, err := ini.Load(setting.CustomConf)
  111. if err != nil {
  112. return fmt.Errorf("load custom config: %v", err)
  113. }
  114. cfg.DeleteSection("i18n")
  115. if err = cfg.SaveTo(setting.CustomConf); err != nil {
  116. return fmt.Errorf("save custom config: %v", err)
  117. }
  118. setting.Langs = strings.Split(strings.Replace(strings.Join(setting.Langs, ","), "fr-CA", "fr-FR", 1), ",")
  119. return nil
  120. }
  121. func trimCommitActionAppUrlPrefix(x *xorm.Engine) error {
  122. type PushCommit struct {
  123. Sha1 string
  124. Message string
  125. AuthorEmail string
  126. AuthorName string
  127. }
  128. type PushCommits struct {
  129. Len int
  130. Commits []*PushCommit
  131. CompareUrl string
  132. }
  133. type Action struct {
  134. ID int64 `xorm:"pk autoincr"`
  135. Content string `xorm:"TEXT"`
  136. }
  137. results, err := x.Query("SELECT `id`,`content` FROM `action` WHERE `op_type`=?", 5)
  138. if err != nil {
  139. return fmt.Errorf("select commit actions: %v", err)
  140. }
  141. sess := x.NewSession()
  142. defer sessionRelease(sess)
  143. if err = sess.Begin(); err != nil {
  144. return err
  145. }
  146. var pushCommits *PushCommits
  147. for _, action := range results {
  148. actID := com.StrTo(string(action["id"])).MustInt64()
  149. if actID == 0 {
  150. continue
  151. }
  152. pushCommits = new(PushCommits)
  153. if err = json.Unmarshal(action["content"], pushCommits); err != nil {
  154. return fmt.Errorf("unmarshal action content[%d]: %v", actID, err)
  155. }
  156. infos := strings.Split(pushCommits.CompareUrl, "/")
  157. if len(infos) <= 4 {
  158. continue
  159. }
  160. pushCommits.CompareUrl = strings.Join(infos[len(infos)-4:], "/")
  161. p, err := json.Marshal(pushCommits)
  162. if err != nil {
  163. return fmt.Errorf("marshal action content[%d]: %v", actID, err)
  164. }
  165. if _, err = sess.Id(actID).Update(&Action{
  166. Content: string(p),
  167. }); err != nil {
  168. return fmt.Errorf("update action[%d]: %v", actID, err)
  169. }
  170. }
  171. return sess.Commit()
  172. }
  173. func issueToIssueLabel(x *xorm.Engine) error {
  174. type IssueLabel struct {
  175. ID int64 `xorm:"pk autoincr"`
  176. IssueID int64 `xorm:"UNIQUE(s)"`
  177. LabelID int64 `xorm:"UNIQUE(s)"`
  178. }
  179. issueLabels := make([]*IssueLabel, 0, 50)
  180. results, err := x.Query("SELECT `id`,`label_ids` FROM `issue`")
  181. if err != nil {
  182. if strings.Contains(err.Error(), "no such column") ||
  183. strings.Contains(err.Error(), "Unknown column") {
  184. return nil
  185. }
  186. return fmt.Errorf("select issues: %v", err)
  187. }
  188. for _, issue := range results {
  189. issueID := com.StrTo(issue["id"]).MustInt64()
  190. // Just in case legacy code can have duplicated IDs for same label.
  191. mark := make(map[int64]bool)
  192. for _, idStr := range strings.Split(string(issue["label_ids"]), "|") {
  193. labelID := com.StrTo(strings.TrimPrefix(idStr, "$")).MustInt64()
  194. if labelID == 0 || mark[labelID] {
  195. continue
  196. }
  197. mark[labelID] = true
  198. issueLabels = append(issueLabels, &IssueLabel{
  199. IssueID: issueID,
  200. LabelID: labelID,
  201. })
  202. }
  203. }
  204. sess := x.NewSession()
  205. defer sessionRelease(sess)
  206. if err = sess.Begin(); err != nil {
  207. return err
  208. }
  209. if err = sess.Sync2(new(IssueLabel)); err != nil {
  210. return fmt.Errorf("Sync2: %v", err)
  211. } else if _, err = sess.Insert(issueLabels); err != nil {
  212. return fmt.Errorf("insert issue-labels: %v", err)
  213. }
  214. return sess.Commit()
  215. }
  216. func attachmentRefactor(x *xorm.Engine) error {
  217. type Attachment struct {
  218. ID int64 `xorm:"pk autoincr"`
  219. UUID string `xorm:"uuid INDEX"`
  220. // For rename purpose.
  221. Path string `xorm:"-"`
  222. NewPath string `xorm:"-"`
  223. }
  224. results, err := x.Query("SELECT * FROM `attachment`")
  225. if err != nil {
  226. return fmt.Errorf("select attachments: %v", err)
  227. }
  228. attachments := make([]*Attachment, 0, len(results))
  229. for _, attach := range results {
  230. if !com.IsExist(string(attach["path"])) {
  231. // If the attachment is already missing, there is no point to update it.
  232. continue
  233. }
  234. attachments = append(attachments, &Attachment{
  235. ID: com.StrTo(attach["id"]).MustInt64(),
  236. UUID: gouuid.NewV4().String(),
  237. Path: string(attach["path"]),
  238. })
  239. }
  240. sess := x.NewSession()
  241. defer sessionRelease(sess)
  242. if err = sess.Begin(); err != nil {
  243. return err
  244. }
  245. if err = sess.Sync2(new(Attachment)); err != nil {
  246. return fmt.Errorf("Sync2: %v", err)
  247. }
  248. // Note: Roll back for rename can be a dead loop,
  249. // so produces a backup file.
  250. var buf bytes.Buffer
  251. buf.WriteString("# old path -> new path\n")
  252. // Update database first because this is where error happens the most often.
  253. for _, attach := range attachments {
  254. if _, err = sess.Id(attach.ID).Update(attach); err != nil {
  255. return err
  256. }
  257. attach.NewPath = path.Join(setting.AttachmentPath, attach.UUID[0:1], attach.UUID[1:2], attach.UUID)
  258. buf.WriteString(attach.Path)
  259. buf.WriteString("\t")
  260. buf.WriteString(attach.NewPath)
  261. buf.WriteString("\n")
  262. }
  263. // Then rename attachments.
  264. isSucceed := true
  265. defer func() {
  266. if isSucceed {
  267. return
  268. }
  269. dumpPath := path.Join(setting.LogRootPath, "attachment_path.dump")
  270. ioutil.WriteFile(dumpPath, buf.Bytes(), 0666)
  271. fmt.Println("Fail to rename some attachments, old and new paths are saved into:", dumpPath)
  272. }()
  273. for _, attach := range attachments {
  274. if err = os.MkdirAll(path.Dir(attach.NewPath), os.ModePerm); err != nil {
  275. isSucceed = false
  276. return err
  277. }
  278. if err = os.Rename(attach.Path, attach.NewPath); err != nil {
  279. isSucceed = false
  280. return err
  281. }
  282. }
  283. return sess.Commit()
  284. }
  285. func renamePullRequestFields(x *xorm.Engine) (err error) {
  286. type PullRequest struct {
  287. ID int64 `xorm:"pk autoincr"`
  288. PullID int64 `xorm:"INDEX"`
  289. PullIndex int64
  290. HeadBarcnh string
  291. IssueID int64 `xorm:"INDEX"`
  292. Index int64
  293. HeadBranch string
  294. }
  295. if err = x.Sync(new(PullRequest)); err != nil {
  296. return fmt.Errorf("sync: %v", err)
  297. }
  298. results, err := x.Query("SELECT `id`,`pull_id`,`pull_index`,`head_barcnh` FROM `pull_request`")
  299. if err != nil {
  300. if strings.Contains(err.Error(), "no such column") {
  301. return nil
  302. }
  303. return fmt.Errorf("select pull requests: %v", err)
  304. }
  305. sess := x.NewSession()
  306. defer sessionRelease(sess)
  307. if err = sess.Begin(); err != nil {
  308. return err
  309. }
  310. var pull *PullRequest
  311. for _, pr := range results {
  312. pull = &PullRequest{
  313. ID: com.StrTo(pr["id"]).MustInt64(),
  314. IssueID: com.StrTo(pr["pull_id"]).MustInt64(),
  315. Index: com.StrTo(pr["pull_index"]).MustInt64(),
  316. HeadBranch: string(pr["head_barcnh"]),
  317. }
  318. if pull.Index == 0 {
  319. continue
  320. }
  321. if _, err = sess.Id(pull.ID).Update(pull); err != nil {
  322. return err
  323. }
  324. }
  325. return sess.Commit()
  326. }
  327. func cleanUpMigrateRepoInfo(x *xorm.Engine) (err error) {
  328. type (
  329. User struct {
  330. ID int64 `xorm:"pk autoincr"`
  331. LowerName string
  332. }
  333. Repository struct {
  334. ID int64 `xorm:"pk autoincr"`
  335. OwnerID int64
  336. LowerName string
  337. }
  338. )
  339. repos := make([]*Repository, 0, 25)
  340. if err = x.Where("is_mirror=?", false).Find(&repos); err != nil {
  341. return fmt.Errorf("select all non-mirror repositories: %v", err)
  342. }
  343. var user *User
  344. for _, repo := range repos {
  345. user = &User{ID: repo.OwnerID}
  346. has, err := x.Get(user)
  347. if err != nil {
  348. return fmt.Errorf("get owner of repository[%d - %d]: %v", repo.ID, repo.OwnerID, err)
  349. } else if !has {
  350. continue
  351. }
  352. configPath := filepath.Join(setting.RepoRootPath, user.LowerName, repo.LowerName+".git/config")
  353. // In case repository file is somehow missing.
  354. if !com.IsFile(configPath) {
  355. continue
  356. }
  357. cfg, err := ini.Load(configPath)
  358. if err != nil {
  359. return fmt.Errorf("open config file: %v", err)
  360. }
  361. cfg.DeleteSection("remote \"origin\"")
  362. if err = cfg.SaveToIndent(configPath, "\t"); err != nil {
  363. return fmt.Errorf("save config file: %v", err)
  364. }
  365. }
  366. return nil
  367. }
  368. func generateOrgRandsAndSalt(x *xorm.Engine) (err error) {
  369. type User struct {
  370. ID int64 `xorm:"pk autoincr"`
  371. Rands string `xorm:"VARCHAR(10)"`
  372. Salt string `xorm:"VARCHAR(10)"`
  373. }
  374. orgs := make([]*User, 0, 10)
  375. if err = x.Where("type=1").And("rands=''").Find(&orgs); err != nil {
  376. return fmt.Errorf("select all organizations: %v", err)
  377. }
  378. sess := x.NewSession()
  379. defer sessionRelease(sess)
  380. if err = sess.Begin(); err != nil {
  381. return err
  382. }
  383. for _, org := range orgs {
  384. org.Rands = base.GetRandomString(10)
  385. org.Salt = base.GetRandomString(10)
  386. if _, err = sess.Id(org.ID).Update(org); err != nil {
  387. return err
  388. }
  389. }
  390. return sess.Commit()
  391. }
  392. type TAction struct {
  393. ID int64 `xorm:"pk autoincr"`
  394. CreatedUnix int64
  395. }
  396. func (t *TAction) TableName() string { return "action" }
  397. type TNotice struct {
  398. ID int64 `xorm:"pk autoincr"`
  399. CreatedUnix int64
  400. }
  401. func (t *TNotice) TableName() string { return "notice" }
  402. type TComment struct {
  403. ID int64 `xorm:"pk autoincr"`
  404. CreatedUnix int64
  405. }
  406. func (t *TComment) TableName() string { return "comment" }
  407. type TIssue struct {
  408. ID int64 `xorm:"pk autoincr"`
  409. DeadlineUnix int64
  410. CreatedUnix int64
  411. UpdatedUnix int64
  412. }
  413. func (t *TIssue) TableName() string { return "issue" }
  414. type TMilestone struct {
  415. ID int64 `xorm:"pk autoincr"`
  416. DeadlineUnix int64
  417. ClosedDateUnix int64
  418. }
  419. func (t *TMilestone) TableName() string { return "milestone" }
  420. type TAttachment struct {
  421. ID int64 `xorm:"pk autoincr"`
  422. CreatedUnix int64
  423. }
  424. func (t *TAttachment) TableName() string { return "attachment" }
  425. type TLoginSource struct {
  426. ID int64 `xorm:"pk autoincr"`
  427. CreatedUnix int64
  428. UpdatedUnix int64
  429. }
  430. func (t *TLoginSource) TableName() string { return "login_source" }
  431. type TPull struct {
  432. ID int64 `xorm:"pk autoincr"`
  433. MergedUnix int64
  434. }
  435. func (t *TPull) TableName() string { return "pull_request" }
  436. type TRelease struct {
  437. ID int64 `xorm:"pk autoincr"`
  438. CreatedUnix int64
  439. }
  440. func (t *TRelease) TableName() string { return "release" }
  441. type TRepo struct {
  442. ID int64 `xorm:"pk autoincr"`
  443. CreatedUnix int64
  444. UpdatedUnix int64
  445. }
  446. func (t *TRepo) TableName() string { return "repository" }
  447. type TMirror struct {
  448. ID int64 `xorm:"pk autoincr"`
  449. UpdatedUnix int64
  450. NextUpdateUnix int64
  451. }
  452. func (t *TMirror) TableName() string { return "mirror" }
  453. type TPublicKey struct {
  454. ID int64 `xorm:"pk autoincr"`
  455. CreatedUnix int64
  456. UpdatedUnix int64
  457. }
  458. func (t *TPublicKey) TableName() string { return "public_key" }
  459. type TDeployKey struct {
  460. ID int64 `xorm:"pk autoincr"`
  461. CreatedUnix int64
  462. UpdatedUnix int64
  463. }
  464. func (t *TDeployKey) TableName() string { return "deploy_key" }
  465. type TAccessToken struct {
  466. ID int64 `xorm:"pk autoincr"`
  467. CreatedUnix int64
  468. UpdatedUnix int64
  469. }
  470. func (t *TAccessToken) TableName() string { return "access_token" }
  471. type TUser struct {
  472. ID int64 `xorm:"pk autoincr"`
  473. CreatedUnix int64
  474. UpdatedUnix int64
  475. }
  476. func (t *TUser) TableName() string { return "user" }
  477. type TWebhook struct {
  478. ID int64 `xorm:"pk autoincr"`
  479. CreatedUnix int64
  480. UpdatedUnix int64
  481. }
  482. func (t *TWebhook) TableName() string { return "webhook" }
  483. func convertDateToUnix(x *xorm.Engine) (err error) {
  484. log.Info("This migration could take up to minutes, please be patient.")
  485. type Bean struct {
  486. ID int64 `xorm:"pk autoincr"`
  487. Created time.Time
  488. Updated time.Time
  489. Merged time.Time
  490. Deadline time.Time
  491. ClosedDate time.Time
  492. NextUpdate time.Time
  493. }
  494. var tables = []struct {
  495. name string
  496. cols []string
  497. bean interface{}
  498. }{
  499. {"action", []string{"created"}, new(TAction)},
  500. {"notice", []string{"created"}, new(TNotice)},
  501. {"comment", []string{"created"}, new(TComment)},
  502. {"issue", []string{"deadline", "created", "updated"}, new(TIssue)},
  503. {"milestone", []string{"deadline", "closed_date"}, new(TMilestone)},
  504. {"attachment", []string{"created"}, new(TAttachment)},
  505. {"login_source", []string{"created", "updated"}, new(TLoginSource)},
  506. {"pull_request", []string{"merged"}, new(TPull)},
  507. {"release", []string{"created"}, new(TRelease)},
  508. {"repository", []string{"created", "updated"}, new(TRepo)},
  509. {"mirror", []string{"updated", "next_update"}, new(TMirror)},
  510. {"public_key", []string{"created", "updated"}, new(TPublicKey)},
  511. {"deploy_key", []string{"created", "updated"}, new(TDeployKey)},
  512. {"access_token", []string{"created", "updated"}, new(TAccessToken)},
  513. {"user", []string{"created", "updated"}, new(TUser)},
  514. {"webhook", []string{"created", "updated"}, new(TWebhook)},
  515. }
  516. for _, table := range tables {
  517. log.Info("Converting table: %s", table.name)
  518. if err = x.Sync2(table.bean); err != nil {
  519. return fmt.Errorf("Sync [table: %s]: %v", table.name, err)
  520. }
  521. offset := 0
  522. for {
  523. beans := make([]*Bean, 0, 100)
  524. if err = x.Sql(fmt.Sprintf("SELECT * FROM `%s` ORDER BY id ASC LIMIT 100 OFFSET %d",
  525. table.name, offset)).Find(&beans); err != nil {
  526. return fmt.Errorf("select beans [table: %s, offset: %d]: %v", table.name, offset, err)
  527. }
  528. log.Trace("Table [%s]: offset: %d, beans: %d", table.name, offset, len(beans))
  529. if len(beans) == 0 {
  530. break
  531. }
  532. offset += 100
  533. baseSQL := "UPDATE `" + table.name + "` SET "
  534. for _, bean := range beans {
  535. valSQLs := make([]string, 0, len(table.cols))
  536. for _, col := range table.cols {
  537. fieldSQL := ""
  538. fieldSQL += col + "_unix = "
  539. switch col {
  540. case "deadline":
  541. if bean.Deadline.IsZero() {
  542. continue
  543. }
  544. fieldSQL += com.ToStr(bean.Deadline.Unix())
  545. case "created":
  546. fieldSQL += com.ToStr(bean.Created.Unix())
  547. case "updated":
  548. fieldSQL += com.ToStr(bean.Updated.Unix())
  549. case "closed_date":
  550. fieldSQL += com.ToStr(bean.ClosedDate.Unix())
  551. case "merged":
  552. fieldSQL += com.ToStr(bean.Merged.Unix())
  553. case "next_update":
  554. fieldSQL += com.ToStr(bean.NextUpdate.Unix())
  555. }
  556. valSQLs = append(valSQLs, fieldSQL)
  557. }
  558. if len(valSQLs) == 0 {
  559. continue
  560. }
  561. if _, err = x.Exec(baseSQL + strings.Join(valSQLs, ",") + " WHERE id = " + com.ToStr(bean.ID)); err != nil {
  562. return fmt.Errorf("update bean [table: %s, id: %d]: %v", table.name, bean.ID, err)
  563. }
  564. }
  565. }
  566. }
  567. return nil
  568. }