Skip to content

Commit f89829d

Browse files
committed
fix: removed obsolete _db_migrate() function from SimpleAuth.
- The _db_migrate function is a left over of the beta phase and was poorly implemented. - Fixed Column types and lengths (No breaking change for sqlite.) necessary for using postgres as database. Fixes #137. See comments for an example config with postgres.
1 parent 44a308b commit f89829d

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

otterwiki/auth.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class User(UserMixin, db.Model):
4444
id = db.Column(db.Integer, primary_key=True)
4545
name = db.Column(db.String(128))
4646
email = db.Column(db.String(128), index=True, unique=True)
47-
password_hash = db.Column(db.String(128))
47+
password_hash = db.Column(db.String(512))
4848
first_seen = db.Column(TimeStamp())
4949
last_seen = db.Column(TimeStamp())
5050
is_approved = db.Column(db.Boolean(), default=False)
@@ -59,21 +59,9 @@ def __repr__(self):
5959

6060
def __init__(self):
6161
with app.app_context():
62-
self._db_migrate()
6362
# create tables
6463
db.create_all()
6564

66-
def _db_migrate(self):
67-
from sqlalchemy.exc import OperationalError
68-
with db.engine.begin() as conn:
69-
for column in ['email_confirmed', 'allow_read', 'allow_write', 'allow_upload']:
70-
try:
71-
sqlc = db.text("ALTER TABLE user ADD COLUMN {} BOOLEAN;".format(column))
72-
r = conn.execute(sqlc)
73-
app.logger.warning("_db_migrate: Altered table 'user' added '{}'".format(column))
74-
except OperationalError:
75-
pass
76-
7765
def user_loader(self, id):
7866
return self.User.query.filter_by(id=int(id)).first()
7967

otterwiki/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def process_result_value(self, value, dialect):
2424

2525
class Preferences(db.Model):
2626
name = db.Column(db.String(256), primary_key=True)
27-
value = db.Column(db.String(256))
27+
value = db.Column(db.Text)
2828

2929
def __str__(self):
3030
return '{}: {}'.format(self.name, self.value)

0 commit comments

Comments
 (0)