我目前正在尝试将 Flask 应用程序部署到 Heroku,但在数据库初始化期间遇到错误。
这是我的 models.py 文件:
from app import app
from app import db
from werkzeug.security import generate_password_hash, check_password_hash
from sqlalchemy import create_engine, Column, Integer, String, Date, ForeignKey, event, Boolean, Table
from sqlalchemy.orm import scoped_session, sessionmaker, backref, relationship
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
password = db.Column(db.String(255), nullable=False, server_default='')
email = db.Column(db.String(255), nullable=False, unique=True, index=True)
confirmed_at = db.Column(db.DateTime())
authenticated = db.Column(db.Boolean(), nullable=False, server_default='0')
company_name = db.Column(db.String(100), nullable=False, server_default='')
roles = db.relationship('Role')
def __init__(self, email, company_name, password):
self.email = email …Run Code Online (Sandbox Code Playgroud)