php 迁移 flask,python,flask_Flask的数据库迁移upgrade出错?,python,flask - phpStudy

Flask的数据库迁移upgrade出错?

在本地没有问题,部署heroku时出错了。

求助。。。。。

#!/usr/bin/env python

import os

COV = None

if os.environ.get('FLASK_COVERAGE'):

import coverage

COV = coverage.coverage(branch=True, include='app/*')

COV.start()

from app import create_app, db

from app.models import User, Follow, Role, Permission, Post, Comment

from flask.ext.script import Manager, Shell

from flask.ext.migrate import Migrate, MigrateCommand

app = create_app(os.getenv('FLASK_CONFIG') or 'default')

manager = Manager(app)

migrate = Migrate(app, db)

def make_shell_context():

return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,

Permission=Permission, Post=Post, Comment=Comment)

manager.add_command("shell", Shell(make_context=make_shell_context))

manager.add_command('db', MigrateCommand)

@manager.command

def test(coverage=False):

"""Run the unit tests."""

if coverage and not os.environ.get('FLASK_COVERAGE'):

import sys

os.environ['FLASK_COVERAGE'] = '1'

os.execvp(sys.executable, [sys.executable] + sys.argv)

import unittest

tests = unittest.TestLoader().discover('tests')

unittest.TextTestRunner(verbosity=2).run(tests)

if COV:

COV.stop()

COV.save()

print('Coverage Summary:')

COV.report()

basedir = os.path.abspath(os.path.dirname(__file__))

covdir = os.path.join(basedir, 'tmp/coverage')

COV.html_report(directory=covdir)

print('HTML version: file://%s/index.html' % covdir)

COV.erase()

@manager.command

def profile(length=25, profile_dir=None):

"""Start the application under the code profiler."""

from werkzeug.contrib.profiler import ProfilerMiddleware

app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],

profile_dir=profile_dir)

app.run()

@manager.command

def deploy():

"""Run deployment tasks."""

from flask.ext.migrate import upgrade

from app.models import Role, User

# migrate database to latest revision

upgrade()

# create user roles

Role.insert_roles()

# create self-follows for all users

User.add_self_follows()

if __name__ == '__main__':

manager.run()

(venv)JohntekiMacBook-Air:our-way johnlance$ heroku run python manage.py deploy

Running python manage.py deploy on ourway... up, run.4509

/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.

warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.')

INFO [alembic.runtime.migration] Context impl SQLiteImpl.

INFO [alembic.runtime.migration] Will assume non-transactional DDL.

INFO [alembic.runtime.migration] Running upgrade -> 38c4e85512a9, initial migration

INFO [alembic.runtime.migration] Running upgrade 38c4e85512a9 -> 456a945560f6, login support

INFO [alembic.runtime.migration] Running upgrade 456a945560f6 -> cd5e7b840291, empty message

INFO [alembic.runtime.migration] Running upgrade -> 5626ef4027e5, empty message

Traceback (most recent call last):

File "manage.py", line 74, in

manager.run()

File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run

result = self.handle(sys.argv[0], sys.argv[1:])

File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle

res = handle(*args, **config)

File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/commands.py", line 216, in __call__

return self.run(*args, **kwargs)

File "manage.py", line 64, in deploy

upgrade()

File "/app/.heroku/python/lib/python2.7/site-packages/flask_migrate/__init__.py", line 216, in upgrade

command.upgrade(config, revision, sql=sql, tag=tag)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade

script.run_env()

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/script/base.py", line 397, in run_env

util.load_python_file(self.dir, 'env.py')

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file

module = load_module_py(module_id, path)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py

mod = imp.load_source(module_id, path, fp)

File "migrations/env.py", line 72, in

run_migrations_online()

File "migrations/env.py", line 65, in run_migrations_online

context.run_migrations()

File "", line 8, in run_migrations

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations

self.get_context().run_migrations(**kw)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations

step.migration_fn(**kw)

File "/app/migrations/versions/5626ef4027e5_.py", line 23, in upgrade

sa.UniqueConstraint('name')

File "", line 8, in create_table

File "", line 3, in create_table

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/ops.py", line 1098, in create_table

return operations.invoke(op)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke

return fn(self, operation)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 101, in create_table

operations.impl.create_table(table)

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/ddl/impl.py", line 194, in create_table

self._exec(schema.CreateTable(table))

File "/app/.heroku/python/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec

return conn.execute(construct, *multiparams, **params)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute

return meth(self, multiparams, params)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection

return connection._execute_ddl(self, multiparams, params)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl

compiled

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context

context)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception

exc_info

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause

reraise(type(exception), exception, tb=exc_tb)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context

context)

File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute

cursor.execute(statement, parameters)

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table roles already exists [SQL: u'\nCREATE TABLE roles (\n\tid INTEGER NOT NULL, \n\tname VARCHAR(64), \n\tPRIMARY KEY (id), \n\tUNIQUE (name)\n)\n\n']

相关阅读:

SVN重新登录问题

node的package.json文件中,依赖包是在npmjs.com下载吗?没有相应版本怎么办呢,比如bootstrap4.

redis subscribe 持久化

为什么函数声明不能在外部调用?

径向模糊是怎么计算出来的?

图片中红色部分间隙哪来的?怎么去除?

mysql数据库中,如何以最快的速度将数据写入数据库?

'\t' 分隔的join问题

Laravel中如何添加新字段,如何指定在某个字段后而不是添加在最后

CentOS7.0安装完mysql,无法登陆,提示access denied

毕业论文管理系统搭建在SAE上会不会让数据安全性降低?为什么?

如何做一个好人

yii 设置场景 验证规则问题

gitignore_global 中 *~ 的含义

javascript作用域链的问题

如何制作安卓 Rom

nginx中的upload module 如何进行权限验证?

鼠标点击后无法使#sideshow的第k个子标签显示

lazylod与scrollLoading为什么都需要给图片加width与height才可生效

scrapy运行出错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值