Make rb_sudo_otp migration idempotent to fix deploy.
init_db creates the table via metadata, so alembic upgrade must check for its existence before issuing CREATE TABLE.
This commit is contained in:
parent
cc2da50569
commit
20161094fc
1 changed files with 12 additions and 9 deletions
|
|
@ -17,15 +17,18 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('rb_sudo_otp',
|
||||
sa.Column('action_key', sa.Unicode(length=256), nullable=False),
|
||||
sa.Column('code', sa.Unicode(length=8), nullable=False),
|
||||
sa.Column('action', sa.Unicode(length=512), nullable=False),
|
||||
sa.Column('client_ip', sa.Unicode(length=45), nullable=True),
|
||||
sa.Column('created_at', sa.BigInteger(), nullable=False),
|
||||
sa.Column('expires_at', sa.BigInteger(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('action_key'),
|
||||
)
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
if 'rb_sudo_otp' not in inspector.get_table_names():
|
||||
op.create_table('rb_sudo_otp',
|
||||
sa.Column('action_key', sa.Unicode(length=256), nullable=False),
|
||||
sa.Column('code', sa.Unicode(length=8), nullable=False),
|
||||
sa.Column('action', sa.Unicode(length=512), nullable=False),
|
||||
sa.Column('client_ip', sa.Unicode(length=45), nullable=True),
|
||||
sa.Column('created_at', sa.BigInteger(), nullable=False),
|
||||
sa.Column('expires_at', sa.BigInteger(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('action_key'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue