/ migrations / versions / 002_add_project_options.py
002_add_project_options.py
 1  from sqlalchemy import text, Column, Text
 2  from alembic import op
 3  
 4  # revision identifiers, used by Alembic.
 5  revision = '002'
 6  down_revision = '001'
 7  branch_labels = None
 8  depends_on = None
 9  
10  def upgrade():
11      # Add options column to projects table
12      try:
13          op.add_column('projects', Column('options', Text(), nullable=True))
14      except Exception as e:
15          print(e)
16      
17      # Set default value for existing projects
18      try:
19          op.execute(text("UPDATE projects SET options = '{\"logging\": true}' WHERE options IS NULL"))
20      except Exception as e:
21          print(e)
22  
23  def downgrade():
24      pass