mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
notification subscription - migration
This commit is contained in:
parent
4dddd7724f
commit
614525a97a
3 changed files with 64 additions and 0 deletions
|
@ -23,3 +23,11 @@ REPORT_STATE_ESCALATED = 1
|
|||
REPORT_STATE_APPEALED = 2
|
||||
REPORT_STATE_RESOLVED = 3
|
||||
REPORT_STATE_DISCARDED = -1
|
||||
|
||||
# different types of content notification that people can have. e.g. when a new post is made by a user or in a community.
|
||||
# see NotificationSubscription in models.py
|
||||
NOTIF_USER = 0
|
||||
NOTIF_COMMUNITY = 1
|
||||
NOTIF_TOPIC = 2
|
||||
NOTIF_POST = 3
|
||||
NOTIF_REPLY = 4
|
||||
|
|
|
@ -1283,6 +1283,15 @@ class Report(db.Model):
|
|||
return self.source_instance_id == 1
|
||||
|
||||
|
||||
class NotificationSubscription(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(256)) # to avoid needing to look up the thing subscribed to via entity_id
|
||||
type = db.Column(db.Integer, default=0, index=True) # see constants.py for possible values: NOTIF_*
|
||||
entity_id = db.Column(db.Integer, index=True) # ID of the user, post, community, etc being subscribed to
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) # To whom this subscription belongs
|
||||
created_at = db.Column(db.DateTime, default=utcnow) # Perhaps very old subscriptions can be automatically deleted
|
||||
|
||||
|
||||
class IpBan(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
ip_address = db.Column(db.String(50), index=True)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
"""notification subscription
|
||||
|
||||
Revision ID: 7aee4cb7db24
|
||||
Revises: 944c5ae8f4ba
|
||||
Create Date: 2024-04-19 19:12:59.022726
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7aee4cb7db24'
|
||||
down_revision = '944c5ae8f4ba'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('notification_subscription',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=256), nullable=True),
|
||||
sa.Column('type', sa.Integer(), nullable=True),
|
||||
sa.Column('entity_id', sa.Integer(), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('notification_subscription', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_notification_subscription_entity_id'), ['entity_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_notification_subscription_type'), ['type'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_notification_subscription_user_id'), ['user_id'], unique=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('notification_subscription', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_notification_subscription_user_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_notification_subscription_type'))
|
||||
batch_op.drop_index(batch_op.f('ix_notification_subscription_entity_id'))
|
||||
|
||||
op.drop_table('notification_subscription')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue