mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
Mod log migration #21
This commit is contained in:
parent
24bc4f8618
commit
dd836c6532
2 changed files with 73 additions and 0 deletions
|
@ -1465,6 +1465,19 @@ class PostReplyBookmark(db.Model):
|
|||
created_at = db.Column(db.DateTime, default=utcnow)
|
||||
|
||||
|
||||
class ModLog(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True)
|
||||
community_id = db.Column(db.Integer, db.ForeignKey('community.id'), index=True)
|
||||
type = db.Column(db.String(10)) # 'mod' or 'admin'
|
||||
action = db.Column(db.String(30)) # 'removing post', 'banning from community', etc
|
||||
reason = db.Column(db.String(512))
|
||||
link = db.Column(db.String(512))
|
||||
link_text = db.Column(db.String(512))
|
||||
public = db.Column(db.Boolean, default=False)
|
||||
created_at = db.Column(db.DateTime, default=utcnow)
|
||||
|
||||
|
||||
class IpBan(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
ip_address = db.Column(db.String(50), index=True)
|
||||
|
@ -1506,6 +1519,7 @@ class Site(db.Model):
|
|||
logo_152 = db.Column(db.String(40), default='')
|
||||
logo_32 = db.Column(db.String(40), default='')
|
||||
logo_16 = db.Column(db.String(40), default='')
|
||||
show_inoculation_block = db.Column(db.Boolean, default=True)
|
||||
|
||||
@staticmethod
|
||||
def admins() -> List[User]:
|
||||
|
|
59
migrations/versions/ea5a07acf23c_mod_log.py
Normal file
59
migrations/versions/ea5a07acf23c_mod_log.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
"""mod log
|
||||
|
||||
Revision ID: ea5a07acf23c
|
||||
Revises: 5bee0ac7d99f
|
||||
Create Date: 2024-07-06 14:47:40.409922
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ea5a07acf23c'
|
||||
down_revision = '5bee0ac7d99f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('mod_log',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('community_id', sa.Integer(), nullable=True),
|
||||
sa.Column('type', sa.String(length=10), nullable=True),
|
||||
sa.Column('action', sa.String(length=30), nullable=True),
|
||||
sa.Column('reason', sa.String(length=512), nullable=True),
|
||||
sa.Column('link', sa.String(length=512), nullable=True),
|
||||
sa.Column('link_text', sa.String(length=512), nullable=True),
|
||||
sa.Column('public', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['community_id'], ['community.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('mod_log', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_mod_log_community_id'), ['community_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_mod_log_user_id'), ['user_id'], unique=False)
|
||||
|
||||
with op.batch_alter_table('site', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('show_inoculation_block', sa.Boolean(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
op.execute(sa.DDL('UPDATE "site" SET show_inoculation_block = true'))
|
||||
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('site', schema=None) as batch_op:
|
||||
batch_op.drop_column('show_inoculation_block')
|
||||
|
||||
with op.batch_alter_table('mod_log', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_mod_log_user_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_mod_log_community_id'))
|
||||
|
||||
op.drop_table('mod_log')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue