62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
"""Restrict sharing to accepted friends
|
|
|
|
Revision ID: 342a45f4132a
|
|
Revises: 3a2896986e0e
|
|
Create Date: 2026-10-01 14:50:51.207109
|
|
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "342a45f4132a"
|
|
down_revision = "3a2896986e0e"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
op.execute("UPDATE activity SET visibility = 'friends' WHERE visibility = 'public'")
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"friendship",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("low_id", sa.Integer(), nullable=False),
|
|
sa.Column("high_id", sa.Integer(), nullable=False),
|
|
sa.Column("requested_by", sa.Integer(), nullable=False),
|
|
sa.Column("status", sa.String(length=12), nullable=False),
|
|
sa.CheckConstraint("low_id < high_id"),
|
|
sa.ForeignKeyConstraint(
|
|
["high_id"],
|
|
["user.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["low_id"],
|
|
["user.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["requested_by"],
|
|
["user.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("low_id", "high_id"),
|
|
)
|
|
with op.batch_alter_table("activity", schema=None) as batch_op:
|
|
batch_op.drop_column("share_route")
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# Never restore public visibility as an incidental effect of a rollback.
|
|
op.execute("UPDATE activity SET visibility = 'private' WHERE visibility = 'friends'")
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("activity", schema=None) as batch_op:
|
|
batch_op.add_column(
|
|
sa.Column("share_route", sa.BOOLEAN(), nullable=False, server_default=sa.false())
|
|
)
|
|
|
|
op.drop_table("friendship")
|
|
# ### end Alembic commands ###
|