-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update organization * minor clean up * add minor clarity * k * slight rejigger * alembic fix * update paradigm * delete code! * delete code * minor update
- Loading branch information
1 parent
227aff1
commit 490a687
Showing
8 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
backend/alembic/versions/26b931506ecb_default_chosen_assistants_to_none.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,68 @@ | ||
"""default chosen assistants to none | ||
Revision ID: 26b931506ecb | ||
Revises: 2daa494a0851 | ||
Create Date: 2024-11-12 13:23:29.858995 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "26b931506ecb" | ||
down_revision = "2daa494a0851" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"user", sa.Column("chosen_assistants_new", postgresql.JSONB(), nullable=True) | ||
) | ||
|
||
op.execute( | ||
""" | ||
UPDATE "user" | ||
SET chosen_assistants_new = | ||
CASE | ||
WHEN chosen_assistants = '[-2, -1, 0]' THEN NULL | ||
ELSE chosen_assistants | ||
END | ||
""" | ||
) | ||
|
||
op.drop_column("user", "chosen_assistants") | ||
|
||
op.alter_column( | ||
"user", "chosen_assistants_new", new_column_name="chosen_assistants" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.add_column( | ||
"user", | ||
sa.Column( | ||
"chosen_assistants_old", | ||
postgresql.JSONB(), | ||
nullable=False, | ||
server_default="[-2, -1, 0]", | ||
), | ||
) | ||
|
||
op.execute( | ||
""" | ||
UPDATE "user" | ||
SET chosen_assistants_old = | ||
CASE | ||
WHEN chosen_assistants IS NULL THEN '[-2, -1, 0]'::jsonb | ||
ELSE chosen_assistants | ||
END | ||
""" | ||
) | ||
|
||
op.drop_column("user", "chosen_assistants") | ||
|
||
op.alter_column( | ||
"user", "chosen_assistants_old", new_column_name="chosen_assistants" | ||
) |
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 |
---|---|---|
|
@@ -743,5 +743,4 @@ def delete_persona_by_name( | |
) | ||
|
||
db_session.execute(stmt) | ||
|
||
db_session.commit() |
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