- rename 'collections' -> 'collectionIds', adding migration 0014
- only populate 'collections' array with {name, id} pair for get_crawl() / single archived item
path, but not for aggregate/list methods
- remove Crawl.get_crawl(), redundant with BaseCrawl.get_crawl() version
- ensure _files_to_resources returns an empty [] instead of none if empty (matching BaseCrawl.get_crawl() behavior to Crawl.get_crawl())
- tests: update tests to use collectionIds for id list, add 'collections' for {name, id} test
- frontend: change Crawl object to have collectionIds instead of collections
---------
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
		
	
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			849 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			849 B
		
	
	
	
		
			Python
		
	
	
	
	
	
"""
 | 
						|
Migration 0014 - collections to collectionIDs
 | 
						|
"""
 | 
						|
from btrixcloud.migrations import BaseMigration
 | 
						|
 | 
						|
 | 
						|
MIGRATION_VERSION = "0014"
 | 
						|
 | 
						|
 | 
						|
class Migration(BaseMigration):
 | 
						|
    """Migration class."""
 | 
						|
 | 
						|
    def __init__(self, mdb, migration_version=MIGRATION_VERSION):
 | 
						|
        super().__init__(mdb, migration_version)
 | 
						|
 | 
						|
    async def migrate_up(self):
 | 
						|
        """Perform migration up.
 | 
						|
 | 
						|
        Rename crawl 'collections' field to 'collectionIds'
 | 
						|
        """
 | 
						|
        # pylint: disable=duplicate-code
 | 
						|
        crawls = self.mdb["crawls"]
 | 
						|
        try:
 | 
						|
            await crawls.update_many({}, {"$rename": {"collections": "collectionIds"}})
 | 
						|
        # pylint: disable=broad-exception-caught
 | 
						|
        except Exception as err:
 | 
						|
            print(
 | 
						|
                f"Error renaming crawl 'collections' to 'collectionIds': {err}",
 | 
						|
                flush=True,
 | 
						|
            )
 |