Skip to content

Commit

Permalink
Add flag for participant-only video (#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Aug 10, 2023
1 parent ad462c2 commit 949f8f9
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 9 deletions.
24 changes: 15 additions & 9 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ class Project(UuidMixin, BaseScopedNameMixin, Model):
datasets={'primary', 'without_parent'},
)

livestream_urls = with_roles(
sa.orm.mapped_column(
sa.ARRAY(sa.UnicodeText, dimensions=1),
server_default=sa.text("'{}'::text[]"),
),
read={'all'},
datasets={'primary', 'without_parent'},
)

is_restricted_video: Mapped[bool] = with_roles(
sa.orm.mapped_column(sa.Boolean, default=False, nullable=False),
read={'all'},
datasets={'primary', 'without_parent'},
)

#: Revision number maintained by SQLAlchemy, used for vCal files, starting at 1
revisionid = with_roles(
sa.orm.mapped_column(sa.Integer, nullable=False), read={'all'}
Expand Down Expand Up @@ -285,15 +300,6 @@ class Project(UuidMixin, BaseScopedNameMixin, Model):
deferred=True,
)

livestream_urls = with_roles(
sa.orm.mapped_column(
sa.ARRAY(sa.UnicodeText, dimensions=1),
server_default=sa.text("'{}'::text[]"),
),
read={'all'},
datasets={'primary', 'without_parent'},
)

__table_args__ = (
sa.UniqueConstraint('profile_id', 'name'),
sa.Index('ix_project_search_vector', 'search_vector', postgresql_using='gin'),
Expand Down
52 changes: 52 additions & 0 deletions migrations/versions/d5b374c9e589_add_flag_for_participant_only_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Add flag for participant-only livestreams.
Revision ID: d5b374c9e589
Revises: ee418ce7d057
Create Date: 2023-08-10 19:56:09.419445
"""

from typing import Optional, Tuple, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'd5b374c9e589'
down_revision: str = 'ee418ce7d057'
branch_labels: Optional[Union[str, Tuple[str, ...]]] = None
depends_on: Optional[Union[str, Tuple[str, ...]]] = None


def upgrade(engine_name: str = '') -> None:
"""Upgrade all databases."""
# Do not modify. Edit `upgrade_` instead
globals().get(f'upgrade_{engine_name}', lambda: None)()


def downgrade(engine_name: str = '') -> None:
"""Downgrade all databases."""
# Do not modify. Edit `downgrade_` instead
globals().get(f'downgrade_{engine_name}', lambda: None)()


def upgrade_() -> None:
"""Upgrade database bind ''."""
with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.add_column(
sa.Column(
'is_restricted_video',
sa.Boolean(),
nullable=True,
server_default=sa.false(),
)
)
batch_op.alter_column(
'is_restricted_video', nullable=False, server_default=None
)


def downgrade_() -> None:
"""Downgrade database bind ''."""
with op.batch_alter_table('project', schema=None) as batch_op:
batch_op.drop_column('is_restricted_video')

0 comments on commit 949f8f9

Please sign in to comment.