mirror of
https://github.com/optim-enterprises-bv/Mailu.git
synced 2025-10-30 17:47:55 +00:00
Revert "Make current migrations work with postgresql"
This reverts commit 9b9f3731f6.
This commit is contained in:
@@ -8,9 +8,8 @@ RUN mkdir -p /app
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements-prod.txt requirements.txt
|
COPY requirements-prod.txt requirements.txt
|
||||||
RUN apk add --no-cache libressl curl postgresql-client \
|
RUN apk add --no-cache openssl curl \
|
||||||
&& apk add --no-cache --virtual build-dep \
|
&& apk add --no-cache --virtual build-dep openssl-dev libffi-dev python3-dev build-base \
|
||||||
libressl-dev libffi-dev python3-dev build-base postgresql-dev \
|
|
||||||
&& pip3 install -r requirements.txt \
|
&& pip3 install -r requirements.txt \
|
||||||
&& apk del --no-cache build-dep
|
&& apk del --no-cache build-dep
|
||||||
|
|
||||||
|
|||||||
@@ -80,17 +80,14 @@ class ConfigManager(dict):
|
|||||||
key: os.environ.get(key, value)
|
key: os.environ.get(key, value)
|
||||||
for key, value in DEFAULT_CONFIG.items()
|
for key, value in DEFAULT_CONFIG.items()
|
||||||
})
|
})
|
||||||
|
if self.config['SQL_FLAVOR'] != 'sqlite'
|
||||||
|
self.setsql()
|
||||||
|
app.config = self
|
||||||
|
|
||||||
def setsql(self):
|
def setsql(self)
|
||||||
if not self.config['DB_PW']:
|
if not self.config['DB_PW']
|
||||||
self.config['DB_PW'] = self.config['SECRET_KEY']
|
self.config['DB_PW'] = self.config['SECRET_KEY']
|
||||||
self.config['SQLALCHEMY_DATABASE_URI'] = '{driver}://{user}:{pw}@{url}/{db}'.format(
|
self.config['SQLALCHEMY_DATABASE_URI'] = '{driver}://{user}:{pw}@{url}/{db}'.format(driver=DB_FLAVOR,user=DB_USER,pw=DB_PW,url=DB_URL,db=DB_NAME)
|
||||||
driver=self.config['DB_FLAVOR'],
|
|
||||||
user=self.config['DB_USER'],
|
|
||||||
pw=self.config['DB_PW'],
|
|
||||||
url=self.config['DB_URL'],
|
|
||||||
db=self.config['DB_NAME']
|
|
||||||
)
|
|
||||||
|
|
||||||
def setdefault(self, key, value):
|
def setdefault(self, key, value):
|
||||||
if key not in self.config:
|
if key not in self.config:
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ 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.0)
|
||||||
|
|
||||||
# Flask-login attributes
|
# Flask-login attributes
|
||||||
is_authenticated = True
|
is_authenticated = True
|
||||||
@@ -463,7 +463,7 @@ class Fetch(Base):
|
|||||||
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', name='protocol'), 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)
|
tls = db.Column(db.Boolean(), nullable=False)
|
||||||
|
|||||||
@@ -12,13 +12,11 @@ down_revision = '49d77a93118e'
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from flask import current_app as app
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
if app.config['DB_FLAVOR'] == 'sqlite':
|
with op.batch_alter_table('user') as batch:
|
||||||
with op.batch_alter_table('user') as batch:
|
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
# set default to 80%
|
# set default to 80%
|
||||||
with op.batch_alter_table('user') as batch:
|
with op.batch_alter_table('user') as batch:
|
||||||
batch.alter_column('spam_threshold', server_default='80')
|
batch.alter_column('spam_threshold', default=80.)
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
connection = op.get_bind()
|
connection = op.get_bind()
|
||||||
@@ -50,4 +50,4 @@ def downgrade():
|
|||||||
)
|
)
|
||||||
# set default to 10/15
|
# set default to 10/15
|
||||||
with op.batch_alter_table('user') as batch:
|
with op.batch_alter_table('user') as batch:
|
||||||
batch.alter_column('spam_threshold', server_default='10')
|
batch.alter_column('spam_threshold', default=10.)
|
||||||
|
|||||||
@@ -12,15 +12,13 @@ down_revision = 'c162ac88012a'
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from flask import current_app as app
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
if app.config['DB_FLAVOR'] == 'sqlite':
|
with op.batch_alter_table('user') as batch:
|
||||||
with op.batch_alter_table('user') as batch:
|
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
with op.batch_alter_table('alias') as batch:
|
||||||
with op.batch_alter_table('alias') as batch:
|
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|||||||
Reference in New Issue
Block a user