generated from one-zero-eight/fastapi-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: tables for workshops and checkins
- Loading branch information
Showing
16 changed files
with
329 additions
and
258 deletions.
There are no files selected for viewing
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
Empty file.
This file was deleted.
Oops, something went wrong.
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,61 @@ | ||
"""empty message | ||
Revision ID: 7fa9ff5cfa18 | ||
Revises: | ||
Create Date: 2024-10-30 01:20:12.174006 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "7fa9ff5cfa18" | ||
down_revision: Union[str, None] = None | ||
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( | ||
"users", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("innohassle_id", sa.String(), nullable=False), | ||
sa.Column("email", sa.String(), nullable=False), | ||
sa.Column("name", sa.String(), nullable=True), | ||
sa.Column("role", sa.Enum("DEFAULT", "ADMIN", name="userrole"), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"workshops", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sa.String(length=255), nullable=False), | ||
sa.Column("alias", sa.String(length=255), nullable=False), | ||
sa.Column("description", sa.Text(), nullable=True), | ||
sa.Column("dtstart", sa.DateTime(), nullable=False), | ||
sa.Column("dtend", sa.DateTime(), nullable=False), | ||
sa.Column("capacity", sa.Integer(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("alias"), | ||
) | ||
op.create_table( | ||
"workshops_checkins", | ||
sa.Column("user_id", sa.Integer(), nullable=False), | ||
sa.Column("workshop_id", sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["workshop_id"], ["users.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("user_id", "workshop_id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("workshops_checkins") | ||
op.drop_table("workshops") | ||
op.drop_table("users") | ||
# ### 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sys | ||
import pathlib | ||
import sys | ||
|
||
import alembic.config | ||
|
||
|
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
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,30 @@ | ||
__all__ = ["Workshop", "CheckIn"] | ||
|
||
import datetime | ||
|
||
from sqlalchemy import ForeignKey, String, Text | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from src.storages.sql.models.base import Base | ||
|
||
|
||
class Workshop(Base): | ||
__tablename__ = "workshops" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
|
||
name: Mapped[str] = mapped_column(String(255), nullable=False) | ||
alias: Mapped[str] = mapped_column(String(255), unique=True) | ||
description: Mapped[str] = mapped_column(Text, nullable=True) | ||
|
||
dtstart: Mapped[datetime.datetime] = mapped_column() | ||
dtend: Mapped[datetime.datetime] = mapped_column() | ||
|
||
capacity: Mapped[int] = mapped_column() | ||
|
||
|
||
class CheckIn(Base): | ||
__tablename__ = "workshops_checkins" | ||
|
||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), primary_key=True) | ||
workshop_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), primary_key=True) |
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