fix: SQL integer column types

We used NUMBER[sic!] as column type in our SQL, which does not exist.
The way SQLite works this mapped to NUMERIC, which is not what we meant,
we really wanted INTEGER here.
This commit is contained in:
ducklet 2024-05-18 18:51:01 +02:00
parent feb60bf658
commit 5eb7211b59

View file

@ -0,0 +1,69 @@
"""fix data types
Revision ID: c08ae04dc482
Revises:
Create Date: 2024-05-18 16:24:31.152480+00:00
"""
from typing import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "c08ae04dc482"
down_revision: str | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("ratings", schema=None) as batch_op:
batch_op.alter_column(
"score",
existing_type=sa.NUMERIC(),
type_=sa.Integer(),
existing_nullable=False,
)
batch_op.alter_column(
"favorite",
existing_type=sa.NUMERIC(),
type_=sa.Integer(),
existing_nullable=True,
)
batch_op.alter_column(
"finished",
existing_type=sa.NUMERIC(),
type_=sa.Integer(),
existing_nullable=True,
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("ratings", schema=None) as batch_op:
batch_op.alter_column(
"finished",
existing_type=sa.Integer(),
type_=sa.NUMERIC(),
existing_nullable=True,
)
batch_op.alter_column(
"favorite",
existing_type=sa.Integer(),
type_=sa.NUMERIC(),
existing_nullable=True,
)
batch_op.alter_column(
"score",
existing_type=sa.Integer(),
type_=sa.NUMERIC(),
existing_nullable=False,
)
# ### end Alembic commands ###