Skip to content

Commit

Permalink
fix timezones issues by adding timezone awareness to database
Browse files Browse the repository at this point in the history
  • Loading branch information
mralext20 committed Jun 26, 2024
1 parent 4d1af71 commit 6999842
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions alembic/versions/1429287bcfdd_fix_timezone_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""fix timezone issues
Revision ID: 1429287bcfdd
Revises: c4f9a55af340
Create Date: 2024-06-26 04:15:53.872117
"""

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 = '1429287bcfdd'
down_revision: Union[str, None] = 'c4f9a55af340'
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.alter_column(
'reminders',
'next_remind',
existing_type=postgresql.TIMESTAMP(),
type_=sa.DateTime(timezone=True),
existing_nullable=False,
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
'reminders',
'next_remind',
existing_type=sa.DateTime(timezone=True),
type_=postgresql.TIMESTAMP(),
existing_nullable=False,
)
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion alexBot/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Reminder(Base):
owner: Mapped[int] = mapped_column(BIGINT(), nullable=False)
guildId: Mapped[Optional[int]] = mapped_column(BIGINT(), nullable=True)
message: Mapped[str] = mapped_column(String(), nullable=False)
next_remind: Mapped[datetime.datetime] = mapped_column(DateTime(), nullable=False)
next_remind: Mapped[datetime.datetime] = mapped_column(DateTime(True), nullable=False)
frequency: Mapped[Optional[datetime.timedelta]] = mapped_column(Interval(), nullable=True)
require_clearing: Mapped[bool] = mapped_column(Boolean(), default=False)
auto_react: Mapped[bool] = mapped_column(Boolean(), default=False)
Expand Down

0 comments on commit 6999842

Please sign in to comment.