Due to update to sqlalchemy, fixed schema nullability

This commit is contained in:
2023-02-26 19:51:29 +05:30
parent 5c7985e392
commit 802eded568
9 changed files with 53 additions and 229 deletions

View File

@ -2,7 +2,7 @@ import logging
from alembic import context
from barker.core.config import settings
from barker.db.base import User
from barker.db.base import reg
from sqlalchemy import create_engine, pool
@ -14,7 +14,7 @@ logging.getLogger("alembic").setLevel(settings.ALEMBIC_LOG_LEVEL)
# This line sets up loggers basically.
target_metadata = User.metadata
target_metadata = reg.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:

View File

@ -0,0 +1,39 @@
"""fix nullability
Revision ID: f135019a4ebf
Revises: 0e326930b8a4
Create Date: 2023-02-22 03:41:23.537388
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "f135019a4ebf"
down_revision = "0e326930b8a4"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column("inventories", "quantity", existing_type=sa.NUMERIC(precision=15, scale=2), nullable=False)
op.alter_column("inventories", "price", existing_type=sa.NUMERIC(precision=15, scale=2), nullable=False)
op.alter_column("inventories", "tax_rate", existing_type=sa.NUMERIC(precision=15, scale=5), nullable=False)
op.alter_column("inventories", "discount", existing_type=sa.NUMERIC(precision=15, scale=5), nullable=False)
op.alter_column("permissions", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
op.alter_column("roles", "name", existing_type=sa.VARCHAR(length=255), nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column("roles", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
op.alter_column("permissions", "name", existing_type=sa.VARCHAR(length=255), nullable=True)
op.alter_column("inventories", "discount", existing_type=sa.NUMERIC(precision=15, scale=5), nullable=True)
op.alter_column("inventories", "tax_rate", existing_type=sa.NUMERIC(precision=15, scale=5), nullable=True)
op.alter_column("inventories", "price", existing_type=sa.NUMERIC(precision=15, scale=2), nullable=True)
op.alter_column("inventories", "quantity", existing_type=sa.NUMERIC(precision=15, scale=2), nullable=True)
# ### end Alembic commands ###