mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-28 03:56:43 +02:00
Make current migrations work with postgresql
This commit is contained in:
parent
2ced020513
commit
9b9f3731f6
@ -8,8 +8,9 @@ RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements-prod.txt requirements.txt
|
||||
RUN apk add --no-cache openssl curl \
|
||||
&& apk add --no-cache --virtual build-dep openssl-dev libffi-dev python3-dev build-base \
|
||||
RUN apk add --no-cache libressl curl postgresql-client \
|
||||
&& apk add --no-cache --virtual build-dep \
|
||||
libressl-dev libffi-dev python3-dev build-base postgresql-dev \
|
||||
&& pip3 install -r requirements.txt \
|
||||
&& apk del --no-cache build-dep
|
||||
|
||||
|
@ -73,14 +73,20 @@ class ConfigManager(dict):
|
||||
key: os.environ.get(key, value)
|
||||
for key, value in DEFAULT_CONFIG.items()
|
||||
})
|
||||
if self.config['SQL_FLAVOR'] != 'sqlite'
|
||||
if self.config['DB_FLAVOR'] != 'sqlite':
|
||||
self.setsql()
|
||||
app.config = self
|
||||
|
||||
def setsql(self)
|
||||
if not self.config['DB_PW']
|
||||
def setsql(self):
|
||||
if not self.config['DB_PW']:
|
||||
self.config['DB_PW'] = self.config['SECRET_KEY']
|
||||
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)
|
||||
self.config['SQLALCHEMY_DATABASE_URI'] = '{driver}://{user}:{pw}@{url}/{db}'.format(
|
||||
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):
|
||||
if key not in self.config:
|
||||
|
@ -287,7 +287,7 @@ class User(Base, Email):
|
||||
# Settings
|
||||
displayed_name = db.Column(db.String(160), nullable=False, default="")
|
||||
spam_enabled = db.Column(db.Boolean(), nullable=False, default=True)
|
||||
spam_threshold = db.Column(db.Integer(), nullable=False, default=80.0)
|
||||
spam_threshold = db.Column(db.Integer(), nullable=False, default=80)
|
||||
|
||||
# Flask-login attributes
|
||||
is_authenticated = True
|
||||
@ -441,7 +441,7 @@ class Fetch(Base):
|
||||
nullable=False)
|
||||
user = db.relationship(User,
|
||||
backref=db.backref('fetches', cascade='all, delete-orphan'))
|
||||
protocol = db.Column(db.Enum('imap', 'pop3'), nullable=False)
|
||||
protocol = db.Column(db.Enum('imap', 'pop3', name='protocol'), nullable=False)
|
||||
host = db.Column(db.String(255), nullable=False)
|
||||
port = db.Column(db.Integer(), nullable=False)
|
||||
tls = db.Column(db.Boolean(), nullable=False)
|
||||
|
@ -12,11 +12,13 @@ down_revision = '49d77a93118e'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from flask import current_app as app
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
if app.config['DB_FLAVOR'] == 'sqlite':
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -35,7 +35,7 @@ def upgrade():
|
||||
)
|
||||
# set default to 80%
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('spam_threshold', default=80.)
|
||||
batch.alter_column('spam_threshold', server_default='80')
|
||||
|
||||
def downgrade():
|
||||
connection = op.get_bind()
|
||||
@ -50,4 +50,4 @@ def downgrade():
|
||||
)
|
||||
# set default to 10/15
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('spam_threshold', default=10.)
|
||||
batch.alter_column('spam_threshold', server_default='10')
|
||||
|
@ -12,13 +12,15 @@ down_revision = 'c162ac88012a'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from flask import current_app as app
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
with op.batch_alter_table('alias') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
if app.config['DB_FLAVOR'] == 'sqlite':
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
with op.batch_alter_table('alias') as batch:
|
||||
batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -44,3 +44,4 @@ visitor==0.1.3
|
||||
Werkzeug==0.14.1
|
||||
WTForms==2.2.1
|
||||
WTForms-Components==0.10.3
|
||||
psycopg2
|
||||
|
Loading…
x
Reference in New Issue
Block a user