Set the different value of column when upgrading table with alembic

Issue #384 resolved
created an issue

I am using PostgreSQL and Alembic for migration. When I added new column to my User table Alembic generated migration with the following script:

from alembic import op
import sqlalchemy as sa
import random

def generate_toke():
    return random.random()

def upgrade():
    op.add_column('user', sa.Column('token', sa.String(), nullable=False ))
    op.execute('some code here')

What I actually want to do is autogenerating the value of token by the generate_toke function for existing data in my DB.Is there a solution?

Comments (1)

  1. Log in to comment