Add migrations using alembic.
* #39 Add Flask-Migrate dep * #39 Make it such that flask db init can run https://github.com/miguelgrinberg/Flask-Migrate/issues/196#issuecomment-381343393 * Run flask db init, update migrations.env, commit artifacts * Set up a script such that you can `docker-compose exec files bash -c 'cd /service; FLASK_APP="files/cli:app" flask '` and have it do whatever flask thing you want * Fix circular dependency * import * is evil * Initial alembic migration, has issues with constraints and nullable columns * Bring alts table up to date with alembic autogenerate * Rerun flask db revision autogenerate * Bring award_relationships table up to date with alembic autogenerate * [#39/alembic] files/classes/__init__.py is evil but is at least explicitly evil now * #39 fix model in files/classes/badges.py * #39 fix model in files/classes/domains.py and files/classes/clients.py * #39 fix models: comment saves, comment flags * #39 fix models: comments * Few more imports * #39 columns that are not nullable should be flagged as not nullable * #39 Add missing indexes to model defs * [#39] add missing unique constraints to model defs * [#39] Temporarily undo any model changes which cause the sqlalchemy model to be out of sync with the actual dump * #39 Deforeignkeyify the correct column to make alembic happy * #39 flask db revision --autogenerate now creates an empty migration * #39 Migration format such that files are listed in creation order * #39 Better first revision * #39 Revert the model changes that were required to get to zero differences between db revision --autogenerate and the existing schema * #39 The first real migration * #39 Ensure that foreign key constraints are named in migration * #39 Alembic migrations for FK constraints, column defs * [#39] Run DB migrations before starting tests * [#39] New test to ensure migrations are up to date * [#39] More descriptive test failure message * Add -T flag to docker-compose exec * [#39] Run alembic migrations when starting the container
This commit is contained in:
parent
19903cccb5
commit
4892b58d10
36 changed files with 693 additions and 129 deletions
|
@ -19,28 +19,28 @@ class Comment(Base):
|
|||
__tablename__ = "comments"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
author_id = Column(Integer, ForeignKey("users.id"))
|
||||
author_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
||||
created_utc = Column(Integer)
|
||||
edited_utc = Column(Integer, default=0)
|
||||
is_banned = Column(Boolean, default=False)
|
||||
ghost = Column(Boolean, default=False)
|
||||
created_utc = Column(Integer, nullable=False)
|
||||
edited_utc = Column(Integer, default=0, nullable=False)
|
||||
is_banned = Column(Boolean, default=False, nullable=False)
|
||||
ghost = Column(Boolean, default=False, nullable=False)
|
||||
bannedfor = Column(Boolean)
|
||||
distinguish_level = Column(Integer, default=0)
|
||||
deleted_utc = Column(Integer, default=0)
|
||||
distinguish_level = Column(Integer, default=0, nullable=False)
|
||||
deleted_utc = Column(Integer, default=0, nullable=False)
|
||||
is_approved = Column(Integer, ForeignKey("users.id"))
|
||||
level = Column(Integer, default=1)
|
||||
level = Column(Integer, default=1, nullable=False)
|
||||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||
top_comment_id = Column(Integer)
|
||||
over_18 = Column(Boolean, default=False)
|
||||
is_bot = Column(Boolean, default=False)
|
||||
over_18 = Column(Boolean, default=False, nullable=False)
|
||||
is_bot = Column(Boolean, default=False, nullable=False)
|
||||
is_pinned = Column(String)
|
||||
is_pinned_utc = Column(Integer)
|
||||
sentto = Column(Integer, ForeignKey("users.id"))
|
||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
upvotes = Column(Integer, default=1)
|
||||
downvotes = Column(Integer, default=0)
|
||||
realupvotes = Column(Integer, default=1)
|
||||
upvotes = Column(Integer, default=1, nullable=False)
|
||||
downvotes = Column(Integer, default=0, nullable=False)
|
||||
realupvotes = Column(Integer, default=1, nullable=False)
|
||||
body = Column(String)
|
||||
body_html = Column(String)
|
||||
ban_reason = Column(String)
|
||||
|
@ -49,6 +49,12 @@ class Comment(Base):
|
|||
wordle_result = Column(String)
|
||||
treasure_amount = Column(String)
|
||||
|
||||
Index('comment_parent_index', parent_comment_id)
|
||||
Index('comment_post_id_index', parent_submission)
|
||||
Index('comments_user_index', author_id)
|
||||
Index('fki_comment_approver_fkey', is_approved)
|
||||
Index('fki_comment_sentto_fkey', sentto)
|
||||
|
||||
oauth_app = relationship("OauthApp", viewonly=True)
|
||||
post = relationship("Submission", viewonly=True)
|
||||
author = relationship("User", primaryjoin="User.id==Comment.author_id")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue