fix(migrations): add default for refresh_token_expires_at to avoid tokens are cleaned
This commit is contained in:
@@ -9,6 +9,7 @@ Create Date: 2025-10-02 10:50:21.169065
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
@@ -25,6 +26,9 @@ def upgrade() -> None:
|
|||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.add_column("oauth_tokens", sa.Column("refresh_token_expires_at", sa.DateTime(), nullable=True))
|
op.add_column("oauth_tokens", sa.Column("refresh_token_expires_at", sa.DateTime(), nullable=True))
|
||||||
op.create_index(op.f("ix_oauth_tokens_expires_at"), "oauth_tokens", ["expires_at"], unique=False)
|
op.create_index(op.f("ix_oauth_tokens_expires_at"), "oauth_tokens", ["expires_at"], unique=False)
|
||||||
|
expires_at = datetime.now() + timedelta(days=15)
|
||||||
|
expires_at_str = expires_at.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
op.execute(f"UPDATE oauth_tokens SET refresh_token_expires_at = '{expires_at_str}'")
|
||||||
op.create_index(
|
op.create_index(
|
||||||
op.f("ix_oauth_tokens_refresh_token_expires_at"), "oauth_tokens", ["refresh_token_expires_at"], unique=False
|
op.f("ix_oauth_tokens_refresh_token_expires_at"), "oauth_tokens", ["refresh_token_expires_at"], unique=False
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user