We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I'm replacing all the database access implementations I used previously with Fatsapi-sqla, and now I need to integrate it with alembic.
What would be the best way to use Fastapi-sqla in alembic?
Do you have any examples of a standard implementation?
I'm defining my models as follows:
from datetime import datetime from fastapi_sqla import Base from sqlalchemy.dialects.postgresql.json import JSONB from sqlalchemy.ext.mutable import MutableDict from sqlalchemy.sql import expression from sqlalchemy import ( Column, Integer, String, Boolean, UniqueConstraint, PrimaryKeyConstraint, DateTime, text, ) import cuid class EntityModel(Base): __tablename__ = "entities" __table_args__ = ( PrimaryKeyConstraint("id", name="entities_pkey"), UniqueConstraint("business_id", name="entities_business_id_ukey"), ) id = Column(String(25), default=cuid.cuid, nullable=False, primary_key=True) owner = Column(String(25), nullable=False) name = Column(String(128), nullable=False) email = Column(String(255), nullable=False) active = Column( Boolean, nullable=False, default=False, server_default=expression.false() ) status = Column(Integer, nullable=False, default=0, server_default=text("0")) country = Column(String(3), default="BRA", nullable=False) business_id = Column(String(25), nullable=False) external_id = Column(String(128), nullable=True) partner_id = Column(String(25), nullable=True) profile = Column(MutableDict.as_mutable(JSONB)) created_at = Column( DateTime(timezone=False), default=datetime.utcnow, nullable=False ) updated_at = Column( DateTime(timezone=False), default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False, ) def __init__(self, *args, **kwargs): if "id" not in kwargs: kwargs["id"] = cuid.cuid() super(EntityModel, self).__init__(*args, **kwargs)
Is this the best way to do it ?
Thanks
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
I'm replacing all the database access implementations I used previously with Fatsapi-sqla, and now I need to integrate it with alembic.
What would be the best way to use Fastapi-sqla in alembic?
Do you have any examples of a standard implementation?
I'm defining my models as follows:
Is this the best way to do it ?
Thanks
The text was updated successfully, but these errors were encountered: