diff --git a/tildes/alembic/env.py b/tildes/alembic/env.py index 3eb9fe2..944f6a4 100644 --- a/tildes/alembic/env.py +++ b/tildes/alembic/env.py @@ -11,22 +11,11 @@ config = context.config # This line sets up loggers basically. fileConfig(config.config_file_name) -# import all DatabaseModel subclasses here for autogenerate support -from tildes.models.comment import ( - Comment, - CommentLabel, - CommentNotification, - CommentVote, -) -from tildes.models.group import Group, GroupSubscription -from tildes.models.log import Log -from tildes.models.message import MessageConversation, MessageReply -from tildes.models.scraper import ScraperResult -from tildes.models.topic import Topic, TopicVisit, TopicVote -from tildes.models.user import User, UserGroupSettings, UserInviteCode +from tildes.database_models import * from tildes.models import DatabaseModel + target_metadata = DatabaseModel.metadata # other values from the config, defined by the needs of env.py, diff --git a/tildes/scripts/initialize_db.py b/tildes/scripts/initialize_db.py index e0655a9..d868207 100644 --- a/tildes/scripts/initialize_db.py +++ b/tildes/scripts/initialize_db.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later """Script for doing the initial setup of database tables.""" -# pylint: disable=wrong-import-order +# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-order import os import subprocess @@ -12,6 +12,7 @@ from alembic import command from alembic.config import Config from sqlalchemy.engine import Connectable, Engine +from tildes.database_models import * # noqa from tildes.lib.database import get_session_from_config from tildes.models import DatabaseModel from tildes.models.group import Group diff --git a/tildes/tildes/database_models.py b/tildes/tildes/database_models.py new file mode 100644 index 0000000..089be4b --- /dev/null +++ b/tildes/tildes/database_models.py @@ -0,0 +1,19 @@ +"""Module that imports all DatabaseModel subclasses. + +This module shouldn't really be used for anything directly. It's for convenience so that +both Alembic and the script for initializing the database can simply import * from here. +""" +# pylint: disable=unused-import + +from tildes.models.comment import ( + Comment, + CommentLabel, + CommentNotification, + CommentVote, +) +from tildes.models.group import Group, GroupSubscription +from tildes.models.log import Log +from tildes.models.message import MessageConversation, MessageReply +from tildes.models.scraper import ScraperResult +from tildes.models.topic import Topic, TopicVisit, TopicVote +from tildes.models.user import User, UserGroupSettings, UserInviteCode