From 9905680041532efebcc9916e6aa370e862cc44a3 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 26 Aug 2023 13:10:01 +1200 Subject: [PATCH] indexible fields - controls external search --- app/models.py | 2 + ...e81_indexable_fields_controls_external_.py | 44 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 migrations/versions/f52c490d4e81_indexable_fields_controls_external_.py diff --git a/app/models.py b/app/models.py index 3cdf69ac..db570c8f 100644 --- a/app/models.py +++ b/app/models.py @@ -84,6 +84,7 @@ class User(UserMixin, db.Model): stripe_customer_id = db.Column(db.String(50)) stripe_subscription_id = db.Column(db.String(50)) searchable = db.Column(db.Boolean, default=True) + indexable = db.Column(db.Boolean, default=False) ap_id = db.Column(db.String(255), index=True) ap_profile_id = db.Column(db.String(255)) @@ -181,6 +182,7 @@ class Post(db.Model): nsfw = db.Column(db.Boolean, default=False) nsfl = db.Column(db.Boolean, default=False) sticky = db.Column(db.Boolean, default=False) + indexable = db.Column(db.Boolean, default=False) created_at = db.Column(db.DateTime, index=True, default=datetime.utcnow) posted_at = db.Column(db.DateTime, index=True, default=datetime.utcnow) last_active = db.Column(db.DateTime, index=True, default=datetime.utcnow) diff --git a/migrations/versions/f52c490d4e81_indexable_fields_controls_external_.py b/migrations/versions/f52c490d4e81_indexable_fields_controls_external_.py new file mode 100644 index 00000000..bd5d1dba --- /dev/null +++ b/migrations/versions/f52c490d4e81_indexable_fields_controls_external_.py @@ -0,0 +1,44 @@ +"""indexable fields - controls external search + +Revision ID: f52c490d4e81 +Revises: e8fe5eff9532 +Create Date: 2023-08-26 13:09:31.328816 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f52c490d4e81' +down_revision = 'e8fe5eff9532' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('community', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_community_ap_profile_id'), ['ap_profile_id'], unique=False) + + with op.batch_alter_table('post', schema=None) as batch_op: + batch_op.add_column(sa.Column('indexable', sa.Boolean(), nullable=True)) + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.add_column(sa.Column('indexable', sa.Boolean(), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_column('indexable') + + with op.batch_alter_table('post', schema=None) as batch_op: + batch_op.drop_column('indexable') + + with op.batch_alter_table('community', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_community_ap_profile_id')) + + # ### end Alembic commands ###