-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extras field of records should not be None/NULL
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
qcfractal/qcfractal/alembic/versions/2024-10-30-03c96181c90f_record_extras_not_nullable.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,33 @@ | ||
"""record extras not nullable | ||
Revision ID: 03c96181c90f | ||
Revises: 73b4838a6839 | ||
Create Date: 2024-10-30 11:07:37.641631 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "03c96181c90f" | ||
down_revision = "73b4838a6839" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.execute("""UPDATE base_record SET extras = '{}' WHERE extras IS NULL""") | ||
op.alter_column("base_record", "extras", existing_type=postgresql.JSONB(astext_type=sa.Text()), nullable=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
|
||
# No need to set extras to null - empty dict is still just fine | ||
|
||
op.alter_column("base_record", "extras", existing_type=postgresql.JSONB(astext_type=sa.Text()), nullable=True) | ||
# ### end Alembic commands ### |
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