-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from wafflestudio/time_error
시간 서울 시간대로 변경 and 투표 생성시 마감 시간이 현재보다 과거일 수 없도록 변경
- Loading branch information
Showing
7 changed files
with
115 additions
and
18 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
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
76 changes: 76 additions & 0 deletions
76
...alembic/versions/2025_01_10_1832-0a5a02cfb40b_vote의_create_end_datetime를_timestamp로_변경.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,76 @@ | ||
"""Vote의 create, end_datetime를 Timestamp로 변경 | ||
Revision ID: 0a5a02cfb40b | ||
Revises: ac9dd8c234ab | ||
Create Date: 2025-01-10 18:32:23.324963 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '0a5a02cfb40b' | ||
down_revision: Union[str, None] = 'ac9dd8c234ab' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute(f""" | ||
UPDATE vote | ||
SET create_datetime = CONVERT_TZ(create_datetime, 'Asia/Seoul', 'UTC'); | ||
""") | ||
# DATETIME을 TIMESTAMP로 변경 | ||
op.alter_column( | ||
'vote', | ||
'create_datetime', | ||
type_=sa.TIMESTAMP(timezone=False), # TIMESTAMP로 변경 | ||
existing_type=sa.DATETIME(), | ||
existing_nullable=False # 기존 NULL 허용 여부를 유지 # 기존 기본값 유지 | ||
) | ||
op.execute(f""" | ||
UPDATE vote | ||
SET create_datetime = CONVERT_TZ(create_datetime, 'Asia/Seoul', 'UTC'); | ||
""") | ||
# DATETIME을 TIMESTAMP로 변경 | ||
op.alter_column( | ||
'vote', | ||
'end_datetime', | ||
type_=sa.TIMESTAMP(timezone=False), # TIMESTAMP로 변경 | ||
existing_type=sa.DATETIME(), | ||
existing_nullable=False # 기존 NULL 허용 여부를 유지 # 기존 기본값 유지 | ||
) | ||
op.execute(f""" | ||
UPDATE vote | ||
SET end_datetime = CONVERT_TZ(end_datetime, 'Asia/Seoul', 'UTC'); | ||
""") | ||
|
||
|
||
|
||
def downgrade() -> None: | ||
op.alter_column( | ||
'vote', | ||
'end_datetime', | ||
type_=sa.DATETIME(), | ||
existing_type=sa.TIMESTAMP(timezone=False), | ||
existing_nullable=True | ||
) | ||
op.execute(f""" | ||
UPDATE vote | ||
SET end_datetime = CONVERT_TZ(end_datetime, 'UTC', 'Asia/Seoul'); | ||
""") | ||
op.alter_column( | ||
'vote', | ||
'create_datetime', | ||
type_=sa.DATETIME(), | ||
existing_type=sa.TIMESTAMP(timezone=False), | ||
existing_nullable=True | ||
) | ||
op.execute(f""" | ||
UPDATE vote | ||
SET create_datetime = CONVERT_TZ(create_datetime, 'UTC', 'Asia/Seoul'); | ||
""") | ||
pass |
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