Closed ecoerod closed 7 years ago
As an example of the model rewrite. Before:
from sqlalchemy import *
from sqlalchemy.orm import relationship
from models import Base
from models.custom_types import GUID
import uuid
class Donation(Base):
__tablename__ = 'donation'
uuid = Column(GUID, primary_key=True, default=uuid.uuid4)
campaign_uuid = Column(GUID, ForeignKey('campaign.uuid'), nullable=False)
donor_uuid = Column(GUID, ForeignKey('donor.uuid'), nullable=False)
date = Column(Date, nullable=False)
amount = Column(Float(2))
After:
from models import db
from models.custom_types import GUID #Maybe needs to change?
import uuid
class Donation(db.Model):
uuid = db.Column(GUID, primary_key=True, default=uuid.uuid4)
campaign_uuid = db.Column(GUID, db.ForeignKey('campaign.uuid'), nullable=False)
donor_uuid = db.Column(GUID, db.ForeignKey('donor.uuid'), nullable=False)
date = db.Column(db.Date, nullable=False)
amount = db.Column(db.Float(2))
Thanks for including all the details. This should be marked as blocking.
I'm on it. Should be done by tomorrow night.
Ok, here's what I just pushed:
Currently the models all use vanilla SQLAlchemy model, which is fine. However, it's unwieldy to use in Flask in big applications, which is why I suggest to move them into the Flask-SQLAlchemy extension, that we have already installed. There are a few steps in this process, which I'll lay down here, followed by the documentation required:
This process should be done before #5 and #6, if we decide to jump to it. It'll make those other issues easier to complete.