diff --git a/app/models.py b/app/models.py index 0e649eb0..38f67f19 100644 --- a/app/models.py +++ b/app/models.py @@ -634,7 +634,7 @@ class User(UserMixin, db.Model): verification_token = db.Column(db.String(16), index=True) banned = db.Column(db.Boolean, default=False) deleted = db.Column(db.Boolean, default=False) - deleted_by = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) + deleted_by = db.Column(db.Integer, index=True) about = db.Column(db.Text) # markdown about_html = db.Column(db.Text) # html keywords = db.Column(db.String(256)) @@ -1078,7 +1078,7 @@ class Post(db.Model): microblog = db.Column(db.Boolean, default=False) comments_enabled = db.Column(db.Boolean, default=True) deleted = db.Column(db.Boolean, default=False, index=True) - deleted_by = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) + deleted_by = db.Column(db.Integer, index=True) mea_culpa = db.Column(db.Boolean, default=False) has_embed = db.Column(db.Boolean, default=False) reply_count = db.Column(db.Integer, default=0) @@ -1354,7 +1354,7 @@ class PostReply(db.Model): created_at = db.Column(db.DateTime, index=True, default=utcnow) posted_at = db.Column(db.DateTime, index=True, default=utcnow) deleted = db.Column(db.Boolean, default=False, index=True) - deleted_by = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) + deleted_by = db.Column(db.Integer, index=True) ip = db.Column(db.String(50)) from_bot = db.Column(db.Boolean, default=False) up_votes = db.Column(db.Integer, default=0) diff --git a/migrations/versions/7fc066ad475a_deleted_by.py b/migrations/versions/7fc066ad475a_deleted_by.py index e50d4c34..2e30924a 100644 --- a/migrations/versions/7fc066ad475a_deleted_by.py +++ b/migrations/versions/7fc066ad475a_deleted_by.py @@ -21,17 +21,14 @@ def upgrade(): with op.batch_alter_table('post', schema=None) as batch_op: batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True)) batch_op.create_index(batch_op.f('ix_post_deleted_by'), ['deleted_by'], unique=False) - batch_op.create_foreign_key(None, 'user', ['deleted_by'], ['id']) with op.batch_alter_table('post_reply', schema=None) as batch_op: batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True)) batch_op.create_index(batch_op.f('ix_post_reply_deleted_by'), ['deleted_by'], unique=False) - batch_op.create_foreign_key(None, 'user', ['deleted_by'], ['id']) with op.batch_alter_table('user', schema=None) as batch_op: batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True)) batch_op.create_index(batch_op.f('ix_user_deleted_by'), ['deleted_by'], unique=False) - batch_op.create_foreign_key(None, 'user', ['deleted_by'], ['id']) # ### end Alembic commands ### @@ -39,17 +36,14 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('user', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') batch_op.drop_index(batch_op.f('ix_user_deleted_by')) batch_op.drop_column('deleted_by') with op.batch_alter_table('post_reply', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') batch_op.drop_index(batch_op.f('ix_post_reply_deleted_by')) batch_op.drop_column('deleted_by') with op.batch_alter_table('post', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') batch_op.drop_index(batch_op.f('ix_post_deleted_by')) batch_op.drop_column('deleted_by')