Fix remaining migration scripts and remove initdb/flushdb from manage.py

This commit is contained in:
kaiyou
2017-09-17 11:55:12 +02:00
parent 829e4a5e28
commit a96478c496
5 changed files with 70 additions and 62 deletions

View File

@@ -13,18 +13,24 @@ down_revision = '2335c80a6bc3'
from alembic import op
import sqlalchemy as sa
from mailu import app, db
from mailu.admin import models
from mailu import app
fetch_table = sa.Table(
'fetch',
sa.MetaData(),
sa.Column('keep', sa.Boolean())
)
def upgrade():
connection = op.get_bind()
op.add_column('fetch', sa.Column('keep', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()))
# also apply the current config value if set
if app.config.get("FETCHMAIL_KEEP", "False") == "True":
for fetch in models.Fetch.query.all():
fetch.keep = True
db.session.commit()
connection.execute(
fetch_table.update().values(keep=True)
)
def downgrade():