fix: text in numeric column

v0.4
rrr-marble 4 years ago
parent 20d59a61e2
commit 14616e8eb9

@ -10,21 +10,41 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '4968a333a100' revision = "4968a333a100"
down_revision = 'b76b7f791b3b' down_revision = "b76b7f791b3b"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
def upgrade() -> None: def upgrade() -> None:
# ### commands auto generated by Alembic ### # ### commands auto generated by Alembic ###
op.add_column('geodata', sa.Column('depth_min', sa.Float(), sa.Computed("SPLIT_PART(depth,'-',1)", ), nullable=True)) op.add_column(
op.add_column('geodata', sa.Column('depth_max', sa.Float(), sa.Computed("SPLIT_PART(depth,'-',2)", ), nullable=True)) "geodata",
sa.Column(
"depth_min",
sa.Float(),
sa.Computed(
"CAST(SPLIT_PART(depth,'-',1) AS DOUBLE PRECISION)",
),
nullable=True,
),
)
op.add_column(
"geodata",
sa.Column(
"depth_max",
sa.Float(),
sa.Computed(
"CAST(SPLIT_PART(depth,'-',1) AS DOUBLE PRECISION)",
),
nullable=True,
),
)
# ### end Alembic commands ### # ### end Alembic commands ###
def downgrade() -> None: def downgrade() -> None:
# ### commands auto generated by Alembic ### # ### commands auto generated by Alembic ###
op.drop_column('geodata', 'depth_max') op.drop_column("geodata", "depth_max")
op.drop_column('geodata', 'depth_min') op.drop_column("geodata", "depth_min")
# ### end Alembic commands ### # ### end Alembic commands ###

@ -48,8 +48,12 @@ class ItemCreate(ItemBase):
class Item(ItemBase): class Item(ItemBase):
depth_min = Column(Float, Computed("SPLIT_PART(depth,'-',1)")) depth_min = Column(
depth_max = Column(Float, Computed("SPLIT_PART(depth,'-',2)")) Float, Computed("CAST(SPLIT_PART(depth,'-',1) AS DOUBLE PRECISION)")
)
depth_max = Column(
Float, Computed("CAST(SPLIT_PART(depth,'-',2)) AS DOUBLE PRECISION")
)
geodata_search_ts = Column( geodata_search_ts = Column(
TSVECTOR, TSVECTOR,

Loading…
Cancel
Save