lifecycle: migrate: ensure template schema exists before migrating (#8952) Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
		
			
				
	
	
		
			13 lines
		
	
	
		
			388 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
		
			388 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from lifecycle.migrate import BaseMigration
 | 
						|
 | 
						|
 | 
						|
class Migration(BaseMigration):
 | 
						|
    def needs_migration(self) -> bool:
 | 
						|
        self.cur.execute(
 | 
						|
            "SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'template';"
 | 
						|
        )
 | 
						|
        return not bool(self.cur.rowcount)
 | 
						|
 | 
						|
    def run(self):
 | 
						|
        self.cur.execute("CREATE SCHEMA IF NOT EXISTS template; COMMIT;")
 |