forked from langgenius/dify
-
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.
fix(migrations): correct parent_message_id for service-api records (l…
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
api/migrations/versions/2024_10_09_1329-d8e744d88ed6_fix_wrong_service_api_history.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,48 @@ | ||
"""fix wrong service-api history | ||
Revision ID: d8e744d88ed6 | ||
Revises: 33f5fac87f29 | ||
Create Date: 2024-10-09 13:29:23.548498 | ||
""" | ||
from alembic import op | ||
from constants import UUID_NIL | ||
import models as models | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd8e744d88ed6' | ||
down_revision = '33f5fac87f29' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
# (UTC) release date of v0.9.0 | ||
v0_9_0_release_date= '2024-09-29 12:00:00' | ||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
sql = f"""UPDATE | ||
public.messages | ||
SET | ||
parent_message_id = '{UUID_NIL}' | ||
WHERE | ||
invoke_from = 'service-api' | ||
AND parent_message_id IS NULL | ||
AND created_at >= '{v0_9_0_release_date}';""" | ||
op.execute(sql) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
sql = f"""UPDATE | ||
public.messages | ||
SET | ||
parent_message_id = NULL | ||
WHERE | ||
invoke_from = 'service-api' | ||
AND parent_message_id = '{UUID_NIL}' | ||
AND created_at >= '{v0_9_0_release_date}';""" | ||
op.execute(sql) | ||
# ### end Alembic commands ### |