Skip to content

Commit

Permalink
WCM-285: add new columns channel and subchannels
Browse files Browse the repository at this point in the history
  • Loading branch information
stollero committed Sep 12, 2024
1 parent a828219 commit 47826c1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-285.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-285: add new columns channel and subchannels
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""add channels and subchannels columns index
Revision ID: 6cc99f5afdc5
Revises: cf24009572b7
Create Date: 2024-09-12 10:58:00.181930
"""
from typing import Sequence, Union

from alembic import op


# revision identifiers, used by Alembic.
revision: str = '6cc99f5afdc5'
down_revision: Union[str, None] = 'cf24009572b7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
with op.get_context().autocommit_block():
op.create_index(
'ix_properties_channels',
'properties',
['channels'],
unique=False,
postgresql_using='gin',
postgresql_concurrently=True,
if_not_exists=True,
)
op.create_index(
'ix_properties_subchannels',
'properties',
['subchannels'],
unique=False,
postgresql_using='gin',
postgresql_concurrently=True,
if_not_exists=True,
)


def downgrade() -> None:
op.drop_index('ix_properties_subchannels', table_name='properties', postgresql_using='gin')
op.drop_index('ix_properties_channels', table_name='properties', postgresql_using='gin')
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""add channels and subchannels columns
Revision ID: 9aba9394d011
Revises: 5f2720a9a131
Create Date: 2024-09-12 10:56:52.266201
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '9aba9394d011'
down_revision: Union[str, None] = '5f2720a9a131'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
op.add_column('properties', sa.Column('channels', sa.ARRAY(sa.Unicode()), nullable=True))
op.add_column('properties', sa.Column('subchannels', sa.ARRAY(sa.Unicode()), nullable=True))


def downgrade() -> None:
op.drop_column('properties', 'subchannels')
op.drop_column('properties', 'channels')
5 changes: 5 additions & 0 deletions core/src/zeit/connector/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hashlib

from sqlalchemy import (
ARRAY,
TIMESTAMP,
Boolean,
ForeignKey,
Expand Down Expand Up @@ -32,6 +33,8 @@ class Base(sqlalchemy.orm.DeclarativeBase):

class CommonMetadata:
access = mapped_column(Unicode, index=True, info={'namespace': 'document', 'name': 'access'})
channels = mapped_column(ARRAY(Unicode), nullable=True)
subchannels = mapped_column(ARRAY(Unicode), nullable=True)


class ZeitWeb:
Expand Down Expand Up @@ -59,6 +62,8 @@ def __table_args__(cls):
postgresql_using='gin',
postgresql_ops={'unsorted': 'jsonb_path_ops'},
),
Index(f'ix_{cls.__tablename__}_channels', 'channels', postgresql_using='gin'),
Index(f'ix_{cls.__tablename__}_subchannels', 'subchannels', postgresql_using='gin'),
)

id = mapped_column(Uuid(as_uuid=False), primary_key=True)
Expand Down

0 comments on commit 47826c1

Please sign in to comment.