-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871113c
commit b5c11ec
Showing
12 changed files
with
341 additions
and
20 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
alembic/versions/2db361ce1d3d_add_color_for_linked_calendar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Add color for linked calendar | ||
Revision ID: 2db361ce1d3d | ||
Revises: a9f09ae0208d | ||
Create Date: 2023-10-16 23:07:37.504254 | ||
""" | ||
# ruff: noqa: E501 | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "2db361ce1d3d" | ||
down_revision: Union[str, None] = "a9f09ae0208d" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("linked_calendars", sa.Column("color", sa.String(length=255), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("linked_calendars", "color") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
"""Add linked calendars | ||
Revision ID: 85bf4b0af84d | ||
Revises: 0f714fc8defc | ||
Create Date: 2023-10-16 22:34:45.234130 | ||
""" | ||
# ruff: noqa: E501 | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "85bf4b0af84d" | ||
down_revision: Union[str, None] = "0f714fc8defc" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"linked_calendars", | ||
sa.Column("user_id", sa.Integer(), nullable=False), | ||
sa.Column("alias", sa.String(length=255), nullable=False), | ||
sa.Column("url", sa.String(), nullable=False), | ||
sa.Column("is_active", sa.Boolean(), nullable=False), | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sa.String(length=255), nullable=False), | ||
sa.Column("description", sa.Text(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.drop_constraint("workshops_x_ownerships_object_id_fkey", "workshops_x_ownerships") | ||
op.drop_table("workshop_checkins") | ||
op.drop_table("timeslots") | ||
op.drop_table("workshops") | ||
op.drop_table("workshops_x_ownerships") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"workshops_x_ownerships", | ||
sa.Column("object_id", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column("role_alias", sa.VARCHAR(length=255), autoincrement=False, nullable=False), | ||
sa.ForeignKeyConstraint(["object_id"], ["workshops.id"], name="workshops_x_ownerships_object_id_fkey"), | ||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name="workshops_x_ownerships_user_id_fkey"), | ||
sa.PrimaryKeyConstraint("object_id", "user_id", name="workshops_x_ownerships_pkey"), | ||
) | ||
op.create_table( | ||
"workshops", | ||
sa.Column("alias", sa.VARCHAR(), autoincrement=False, nullable=False), | ||
sa.Column("date", sa.DATE(), autoincrement=False, nullable=False), | ||
sa.Column("speaker", sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.Column("capacity", sa.INTEGER(), autoincrement=False, nullable=True), | ||
sa.Column("comment", sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.Column("location", sa.VARCHAR(), autoincrement=False, nullable=True), | ||
sa.Column( | ||
"id", | ||
sa.INTEGER(), | ||
server_default=sa.text("nextval('workshops_id_seq'::regclass)"), | ||
autoincrement=True, | ||
nullable=False, | ||
), | ||
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=False), | ||
sa.PrimaryKeyConstraint("id", name="workshops_pkey"), | ||
sa.UniqueConstraint("alias", name="workshops_alias_key"), | ||
postgresql_ignore_search_path=False, | ||
) | ||
op.create_table( | ||
"timeslots", | ||
sa.Column("workshop_id", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column("sequence", sa.INTEGER(), autoincrement=True, nullable=False), | ||
sa.Column("start", postgresql.TIME(), autoincrement=False, nullable=False), | ||
sa.Column("end", postgresql.TIME(), autoincrement=False, nullable=False), | ||
sa.ForeignKeyConstraint(["workshop_id"], ["workshops.id"], name="timeslots_workshop_id_fkey"), | ||
sa.PrimaryKeyConstraint("sequence", name="timeslots_pkey"), | ||
) | ||
op.create_table( | ||
"workshop_checkins", | ||
sa.Column("workshop_id", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column("user_id", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column("timeslot_sequence", sa.INTEGER(), autoincrement=False, nullable=False), | ||
sa.Column( | ||
"dtstamp", postgresql.TIMESTAMP(), server_default=sa.text("now()"), autoincrement=False, nullable=False | ||
), | ||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name="workshop_checkins_user_id_fkey"), | ||
sa.ForeignKeyConstraint(["workshop_id"], ["workshops.id"], name="workshop_checkins_workshop_id_fkey"), | ||
sa.PrimaryKeyConstraint("workshop_id", "user_id", "timeslot_sequence", name="workshop_checkins_pkey"), | ||
) | ||
op.drop_table("linked_calendars") | ||
# ### end Alembic commands ### |
34 changes: 34 additions & 0 deletions
34
alembic/versions/a9f09ae0208d_add_constraint_for_linked_calendars.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Add constraint for linked calendars | ||
Revision ID: a9f09ae0208d | ||
Revises: 85bf4b0af84d | ||
Create Date: 2023-10-16 22:53:08.602036 | ||
""" | ||
# ruff: noqa: E501 | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "a9f09ae0208d" | ||
down_revision: Union[str, None] = "85bf4b0af84d" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_unique_constraint("unique_user_id_alias", "linked_calendars", ["user_id", "alias"]) | ||
op.drop_constraint("tags_alias_type_key", "tags", type_="unique") | ||
op.create_unique_constraint("unique_alias", "tags", ["alias", "type"]) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint("unique_alias", "tags", type_="unique") | ||
op.create_unique_constraint("tags_alias_type_key", "tags", ["alias", "type"]) | ||
op.drop_constraint("unique_user_id_alias", "linked_calendars", type_="unique") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
__all__ = ["LinkedCalendarView", "LinkedCalendarCreate", "LinkedCalendarUpdate"] | ||
|
||
|
||
from typing import Optional | ||
|
||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class LinkedCalendarView(BaseModel): | ||
""" | ||
Represents a linked calendar instance from the database excluding sensitive information. | ||
""" | ||
|
||
id: int | ||
user_id: int | ||
alias: str | ||
url: str | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
color: Optional[str] = None | ||
is_active: bool = True | ||
|
||
class Config: | ||
orm_mode = True | ||
|
||
|
||
class LinkedCalendarCreate(BaseModel): | ||
""" | ||
Represents a linked calendar instance to be created. | ||
""" | ||
|
||
alias: str | ||
url: str | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
color: Optional[str] = None | ||
is_active: bool = True | ||
|
||
|
||
class LinkedCalendarUpdate(BaseModel): | ||
""" | ||
Represents a linked calendar instance to be updated. | ||
""" | ||
|
||
alias: Optional[str] = None | ||
url: Optional[str] = None | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
color: Optional[str] = None | ||
is_active: Optional[bool] = None |
Oops, something went wrong.
b5c11ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report