mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
deleted_by field - no foreign keys as they were confusing sqlalchemy
This commit is contained in:
parent
d8c75991cd
commit
ba2a97c4ad
2 changed files with 3 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in a new issue