Migrations: Add migration to fill empty info fields and make them non-null.
This commit is contained in:
		
							parent
							
								
									a43b899e94
								
							
						
					
					
						commit
						8ad75f9ecf
					
				
					 1 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
defmodule Pleroma.Repo.Migrations.FixAndSecureUserInfoField do
 | 
			
		||||
  use Ecto.Migration
 | 
			
		||||
 | 
			
		||||
  def up do
 | 
			
		||||
    execute("UPDATE users SET info = '{}'::jsonb WHERE info IS NULL")
 | 
			
		||||
 | 
			
		||||
    execute("ALTER TABLE users
 | 
			
		||||
    ALTER COLUMN info SET NOT NULL
 | 
			
		||||
    ")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def down do
 | 
			
		||||
    execute("ALTER TABLE users
 | 
			
		||||
    ALTER COLUMN info DROP NOT NULL
 | 
			
		||||
    ")
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
		Reference in a new issue