preMigrationChecks performs checks before running migrations
()
| 778 | |
| 779 | // preMigrationChecks performs checks before running migrations |
| 780 | func (s *sqlDatabase) preMigrationChecks() (needsCredentialMigration, migrateTemplates, hasMinAgeField, hasAgentURL bool) { |
| 781 | // Check if credentials need migration |
| 782 | needsCredentialMigration = !s.conn.Migrator().HasTable(&GithubCredentials{}) || |
| 783 | !s.conn.Migrator().HasTable(&GithubEndpoint{}) |
| 784 | |
| 785 | // Check if templates need migration |
| 786 | migrateTemplates = !s.conn.Migrator().HasTable(&Template{}) |
| 787 | |
| 788 | // Check for controller info fields |
| 789 | if s.conn.Migrator().HasTable(&ControllerInfo{}) { |
| 790 | hasMinAgeField = s.conn.Migrator().HasColumn(&ControllerInfo{}, "minimum_job_age_backoff") |
| 791 | hasAgentURL = s.conn.Migrator().HasColumn(&ControllerInfo{}, "agent_url") |
| 792 | } |
| 793 | |
| 794 | return |
| 795 | } |
| 796 | |
| 797 | func (s *sqlDatabase) migrateDB() error { |
| 798 | // Drop obsolete indexes |