migratePoolNullIDs updates pools to set null IDs instead of zero UUIDs
()
| 699 | |
| 700 | // migratePoolNullIDs updates pools to set null IDs instead of zero UUIDs |
| 701 | func (s *sqlDatabase) migratePoolNullIDs() error { |
| 702 | if !s.conn.Migrator().HasTable(&Pool{}) { |
| 703 | return nil |
| 704 | } |
| 705 | |
| 706 | zeroUUID := "00000000-0000-0000-0000-000000000000" |
| 707 | updates := []struct { |
| 708 | column string |
| 709 | query string |
| 710 | }{ |
| 711 | {"repo_id", fmt.Sprintf("update pools set repo_id=NULL where repo_id='%s'", zeroUUID)}, |
| 712 | {"org_id", fmt.Sprintf("update pools set org_id=NULL where org_id='%s'", zeroUUID)}, |
| 713 | {"enterprise_id", fmt.Sprintf("update pools set enterprise_id=NULL where enterprise_id='%s'", zeroUUID)}, |
| 714 | } |
| 715 | |
| 716 | for _, update := range updates { |
| 717 | if err := s.conn.Exec(update.query).Error; err != nil { |
| 718 | return fmt.Errorf("error updating pools %s: %w", update.column, err) |
| 719 | } |
| 720 | } |
| 721 | return nil |
| 722 | } |
| 723 | |
| 724 | // migrateGithubEndpointType adds and initializes endpoint_type column |
| 725 | func (s *sqlDatabase) migrateGithubEndpointType() error { |