Fix migrations for real this time
This commit is contained in:
parent
eef55c1ebb
commit
6312ebea16
3 changed files with 5 additions and 7 deletions
|
@ -46,8 +46,8 @@ class CommentFlag(Base):
|
|||
__tablename__ = "commentflags"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
comment_id = Column(Integer, ForeignKey("comments.id"), primary_key=False)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=False)
|
||||
comment_id = Column(Integer, ForeignKey("comments.id"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
reason = Column(String)
|
||||
created_utc = Column(Integer, nullable=False)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ def upgrade():
|
|||
op.execute("UPDATE submissions SET filter_state = 'normal';")
|
||||
op.alter_column('submissions', 'filter_state', nullable=False)
|
||||
op.drop_constraint('flags_pkey', 'flags')
|
||||
op.add_column('flags', sa.Column('id', sa.Integer, nullable=False, primary_key=True, autoincrement=True))
|
||||
op.execute('alter table flags add column id serial primary key')
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
|
|
@ -21,12 +21,10 @@ def upgrade():
|
|||
op.execute("UPDATE comments SET filter_state = 'normal';")
|
||||
op.alter_column('comments', 'filter_state', nullable=False)
|
||||
op.drop_constraint('commentflags_pkey', 'commentflags')
|
||||
op.add_column('commentflags', sa.Column('id', sa.Integer, nullable=False, primary_key=True, autoincrement=True))
|
||||
op.alter_column('commentflags', 'comment_id', nullable=True)
|
||||
op.alter_column('commentflags', 'user_id', nullable=True)
|
||||
op.execute('alter table commentflags add column id serial primary key')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('comments', 'filter_state')
|
||||
op.drop_column('commentflags', 'id')
|
||||
op.create_primary_key('commentflags_pkey', 'commentflags', ['post_id', 'user_id'])
|
||||
op.create_primary_key('commentflags_pkey', 'commentflags', ['comment_id', 'user_id'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue