You've already forked focalboard
							
							
				mirror of
				https://github.com/mattermost/focalboard.git
				synced 2025-10-31 00:17:42 +02:00 
			
		
		
		
	add cyclo complexity, update migrate() to use defer (#3257)
This commit is contained in:
		| @@ -67,6 +67,7 @@ linters: | ||||
|     - unconvert | ||||
|     - unused | ||||
|     - whitespace | ||||
|     - gocyclo | ||||
|  | ||||
| issues: | ||||
|   exclude-rules: | ||||
|   | ||||
| @@ -65,3 +65,4 @@ linters: | ||||
|     - unconvert | ||||
|     - unused | ||||
|     - whitespace | ||||
|     - gocyclo | ||||
|   | ||||
| @@ -204,11 +204,13 @@ func (s *SQLStore) Migrate() error { | ||||
| 		if mutexErr != nil { | ||||
| 			return fmt.Errorf("error creating database mutex: %w", mutexErr) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if s.isPlugin { | ||||
| 		s.logger.Debug("Acquiring cluster lock for Unique IDs migration") | ||||
| 		mutex.Lock() | ||||
| 		defer func() { | ||||
| 			s.logger.Debug("Releasing cluster lock for Unique IDs migration") | ||||
| 			mutex.Unlock() | ||||
| 		}() | ||||
| 	} | ||||
|  | ||||
| 	if err := s.migrateSchemaVersionTable(src.Migrations()); err != nil { | ||||
| @@ -220,10 +222,6 @@ func (s *SQLStore) Migrate() error { | ||||
| 	} | ||||
|  | ||||
| 	if err := s.runUniqueIDsMigration(); err != nil { | ||||
| 		if s.isPlugin { | ||||
| 			s.logger.Debug("Releasing cluster lock for Unique IDs migration") | ||||
| 			mutex.Unlock() | ||||
| 		} | ||||
| 		return fmt.Errorf("error running unique IDs migration: %w", err) | ||||
| 	} | ||||
|  | ||||
| @@ -232,39 +230,21 @@ func (s *SQLStore) Migrate() error { | ||||
| 	} | ||||
|  | ||||
| 	if err := s.runCategoryUUIDIDMigration(); err != nil { | ||||
| 		if s.isPlugin { | ||||
| 			s.logger.Debug("Releasing cluster lock for Unique IDs migration") | ||||
| 			mutex.Unlock() | ||||
| 		} | ||||
| 		return fmt.Errorf("error running categoryID migration: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	if err := s.deleteOldSchemaMigrationTable(); err != nil { | ||||
| 		if s.isPlugin { | ||||
| 			mutex.Unlock() | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := ensureMigrationsAppliedUpToVersion(engine, driver, teamsAndBoardsMigrationRequiredVersion); err != nil { | ||||
| 		if s.isPlugin { | ||||
| 			mutex.Unlock() | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := s.migrateTeamLessBoards(); err != nil { | ||||
| 		if s.isPlugin { | ||||
| 			mutex.Unlock() | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if s.isPlugin { | ||||
| 		s.logger.Debug("Releasing cluster lock for Unique IDs migration") | ||||
| 		mutex.Unlock() | ||||
| 	} | ||||
|  | ||||
| 	return engine.ApplyAll() | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user