diff --git a/gallery/db.py b/gallery/db.py index b94e035..d916bd7 100644 --- a/gallery/db.py +++ b/gallery/db.py @@ -5,7 +5,8 @@ from uuid import uuid4 import os import platformdirs -from sqlalchemy import create_engine, Column, Integer, String, DateTime, ForeignKey, PickleType, func +from sqlalchemy import (create_engine, Column, Integer, String, + DateTime, ForeignKey, PickleType, func) from sqlalchemy.orm import declarative_base, relationship from flask_login import UserMixin @@ -33,7 +34,7 @@ class Users (base, UserMixin): # pylint: disable=too-few-public-methods, C0103 username = Column(String, unique=True, nullable=False) email = Column(String, unique=True, nullable=False) password = Column(String, nullable=False) - joined_at = Column(DateTime, nullable=False, server_default=func.now()) + joined_at = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 posts = relationship('Posts', backref='users') groups = relationship('Groups', backref='users') @@ -52,7 +53,7 @@ class Posts (base): # pylint: disable=too-few-public-methods, C0103 id = Column(Integer, primary_key=True) author_id = Column(Integer, ForeignKey('users.id')) - created_at = Column(DateTime, nullable=False, server_default=func.now()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 filename = Column(String, unique=True, nullable=False) mimetype = Column(String, nullable=False) exif = Column(PickleType, nullable=False) @@ -73,7 +74,7 @@ class Groups (base): # pylint: disable=too-few-public-methods, C0103 name = Column(String, nullable=False) description = Column(String, nullable=False) author_id = Column(Integer, ForeignKey('users.id')) - created_at = Column(DateTime, nullable=False, server_default=func.now()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 junction = relationship('GroupJunction', backref='groups') @@ -86,7 +87,7 @@ class GroupJunction (base): # pylint: disable=too-few-public-methods, C0103 __tablename__ = 'group_junction' id = Column(Integer, primary_key=True) - date_added = Column(DateTime, nullable=False, server_default=func.now()) + date_added = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 group_id = Column(Integer, ForeignKey('groups.id')) post_id = Column(Integer, ForeignKey('posts.id')) @@ -103,7 +104,7 @@ class Logs (base): # pylint: disable=too-few-public-methods, C0103 ip_address = Column(String, nullable=False) code = Column(Integer, nullable=False) note = Column(String, nullable=False) - created_at = Column(DateTime, nullable=False, server_default=func.now()) + created_at = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 class Bans (base): # pylint: disable=too-few-public-methods, C0103 @@ -116,10 +117,10 @@ class Bans (base): # pylint: disable=too-few-public-methods, C0103 ip_address = Column(String, nullable=False) code = Column(Integer, nullable=False) note = Column(String, nullable=False) - banned_at = Column(DateTime, nullable=False, server_default=func.now()) + banned_at = Column(DateTime, nullable=False, server_default=func.now()) # pylint: disable=E1102 # check if database file exists, if not create it if not os.path.isfile(DB_PATH): - base.metadata.create_all(engine) + base.metadata.create_all(engine) print('Database created')