migrateGithubEndpointType adds and initializes endpoint_type column
()
| 723 | |
| 724 | // migrateGithubEndpointType adds and initializes endpoint_type column |
| 725 | func (s *sqlDatabase) migrateGithubEndpointType() error { |
| 726 | if !s.conn.Migrator().HasTable(&GithubEndpoint{}) { |
| 727 | return nil |
| 728 | } |
| 729 | |
| 730 | if s.conn.Migrator().HasColumn(&GithubEndpoint{}, "endpoint_type") { |
| 731 | return nil |
| 732 | } |
| 733 | |
| 734 | if err := s.conn.Migrator().AutoMigrate(&GithubEndpoint{}); err != nil { |
| 735 | return fmt.Errorf("error migrating github endpoints: %w", err) |
| 736 | } |
| 737 | |
| 738 | if err := s.conn.Exec("update github_endpoints set endpoint_type = 'github' where endpoint_type is null").Error; err != nil { |
| 739 | return fmt.Errorf("error updating github endpoints: %w", err) |
| 740 | } |
| 741 | |
| 742 | return nil |
| 743 | } |
| 744 | |
| 745 | // migrateControllerInfo updates controller info with new fields |
| 746 | func (s *sqlDatabase) migrateControllerInfo(hasMinAgeField, hasAgentURL bool) error { |