fix sqlalchemy column definitions

master
Alexander Graf 4 years ago
parent b3f8dacdad
commit 82cf0d843f

@ -369,6 +369,7 @@ class Config(Base):
value = db.Column(JSONEncoded) value = db.Column(JSONEncoded)
# TODO: use sqlalchemy.event.listen() on a store method of object?
@sqlalchemy.event.listens_for(db.session, 'after_commit') @sqlalchemy.event.listens_for(db.session, 'after_commit')
def store_dkim_key(session): def store_dkim_key(session):
""" Store DKIM key on commit """ Store DKIM key on commit
@ -437,8 +438,8 @@ class Domain(Base):
backref=db.backref('manager_of'), lazy='dynamic') backref=db.backref('manager_of'), lazy='dynamic')
max_users = db.Column(db.Integer, nullable=False, default=-1) max_users = db.Column(db.Integer, nullable=False, default=-1)
max_aliases = db.Column(db.Integer, nullable=False, default=-1) max_aliases = db.Column(db.Integer, nullable=False, default=-1)
max_quota_bytes = db.Column(db.BigInteger(), nullable=False, default=0) max_quota_bytes = db.Column(db.BigInteger, nullable=False, default=0)
signup_enabled = db.Column(db.Boolean(), nullable=False, default=False) signup_enabled = db.Column(db.Boolean, nullable=False, default=False)
_dkim_key = None _dkim_key = None
_dkim_key_changed = False _dkim_key_changed = False
@ -688,22 +689,22 @@ class User(Base, Email):
domain = db.relationship(Domain, domain = db.relationship(Domain,
backref=db.backref('users', cascade='all, delete-orphan')) backref=db.backref('users', cascade='all, delete-orphan'))
password = db.Column(db.String(255), nullable=False) password = db.Column(db.String(255), nullable=False)
quota_bytes = db.Column(db.BigInteger(), nullable=False, default=10**9) quota_bytes = db.Column(db.BigInteger, nullable=False, default=10**9)
quota_bytes_used = db.Column(db.BigInteger(), nullable=False, default=0) quota_bytes_used = db.Column(db.BigInteger, nullable=False, default=0)
global_admin = db.Column(db.Boolean(), nullable=False, default=False) global_admin = db.Column(db.Boolean, nullable=False, default=False)
enabled = db.Column(db.Boolean(), nullable=False, default=True) enabled = db.Column(db.Boolean, nullable=False, default=True)
# Features # Features
enable_imap = db.Column(db.Boolean(), nullable=False, default=True) enable_imap = db.Column(db.Boolean, nullable=False, default=True)
enable_pop = db.Column(db.Boolean(), nullable=False, default=True) enable_pop = db.Column(db.Boolean, nullable=False, default=True)
# Filters # Filters
forward_enabled = db.Column(db.Boolean(), nullable=False, default=False) forward_enabled = db.Column(db.Boolean, nullable=False, default=False)
forward_destination = db.Column(CommaSeparatedList(), nullable=True, default=[]) forward_destination = db.Column(CommaSeparatedList, nullable=True, default=list)
forward_keep = db.Column(db.Boolean(), nullable=False, default=True) forward_keep = db.Column(db.Boolean, nullable=False, default=True)
reply_enabled = db.Column(db.Boolean(), nullable=False, default=False) reply_enabled = db.Column(db.Boolean, nullable=False, default=False)
reply_subject = db.Column(db.String(255), nullable=True, default=None) reply_subject = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None) reply_body = db.Column(db.Text, nullable=True, default=None)
reply_startdate = db.Column(db.Date, nullable=False, reply_startdate = db.Column(db.Date, nullable=False,
default=date(1900, 1, 1)) default=date(1900, 1, 1))
reply_enddate = db.Column(db.Date, nullable=False, reply_enddate = db.Column(db.Date, nullable=False,
@ -711,8 +712,8 @@ class User(Base, Email):
# Settings # Settings
displayed_name = db.Column(db.String(160), nullable=False, default='') displayed_name = db.Column(db.String(160), nullable=False, default='')
spam_enabled = db.Column(db.Boolean(), nullable=False, default=True) spam_enabled = db.Column(db.Boolean, nullable=False, default=True)
spam_threshold = db.Column(db.Integer(), nullable=False, default=80) spam_threshold = db.Column(db.Integer, nullable=False, default=80)
# Flask-login attributes # Flask-login attributes
is_authenticated = True is_authenticated = True
@ -822,8 +823,8 @@ class Alias(Base, Email):
domain = db.relationship(Domain, domain = db.relationship(Domain,
backref=db.backref('aliases', cascade='all, delete-orphan')) backref=db.backref('aliases', cascade='all, delete-orphan'))
wildcard = db.Column(db.Boolean(), nullable=False, default=False) wildcard = db.Column(db.Boolean, nullable=False, default=False)
destination = db.Column(CommaSeparatedList, nullable=False, default=[]) destination = db.Column(CommaSeparatedList, nullable=False, default=list)
@classmethod @classmethod
def resolve(cls, localpart, domain_name): def resolve(cls, localpart, domain_name):
@ -878,7 +879,7 @@ class Token(Base):
_dict_hide = {'user', 'user_email'} _dict_hide = {'user', 'user_email'}
_dict_mandatory = {'password'} _dict_mandatory = {'password'}
id = db.Column(db.Integer(), primary_key=True) id = db.Column(db.Integer, primary_key=True)
user_email = db.Column(db.String(255), db.ForeignKey(User.email), user_email = db.Column(db.String(255), db.ForeignKey(User.email),
nullable=False) nullable=False)
user = db.relationship(User, user = db.relationship(User,
@ -908,18 +909,18 @@ class Fetch(Base):
_dict_mandatory = {'protocol', 'host', 'port', 'username', 'password'} _dict_mandatory = {'protocol', 'host', 'port', 'username', 'password'}
_dict_secret = {'password'} _dict_secret = {'password'}
id = db.Column(db.Integer(), primary_key=True) id = db.Column(db.Integer, primary_key=True)
user_email = db.Column(db.String(255), db.ForeignKey(User.email), user_email = db.Column(db.String(255), db.ForeignKey(User.email),
nullable=False) nullable=False)
user = db.relationship(User, user = db.relationship(User,
backref=db.backref('fetches', cascade='all, delete-orphan')) backref=db.backref('fetches', cascade='all, delete-orphan'))
protocol = db.Column(db.Enum('imap', 'pop3'), nullable=False) protocol = db.Column(db.Enum('imap', 'pop3'), nullable=False)
host = db.Column(db.String(255), nullable=False) host = db.Column(db.String(255), nullable=False)
port = db.Column(db.Integer(), nullable=False) port = db.Column(db.Integer, nullable=False)
tls = db.Column(db.Boolean(), nullable=False, default=False) tls = db.Column(db.Boolean, nullable=False, default=False)
username = db.Column(db.String(255), nullable=False) username = db.Column(db.String(255), nullable=False)
password = db.Column(db.String(255), nullable=False) password = db.Column(db.String(255), nullable=False)
keep = db.Column(db.Boolean(), nullable=False, default=False) keep = db.Column(db.Boolean, nullable=False, default=False)
last_check = db.Column(db.DateTime, nullable=True) last_check = db.Column(db.DateTime, nullable=True)
error = db.Column(db.String(1023), nullable=True) error = db.Column(db.String(1023), nullable=True)

Loading…
Cancel
Save