Add some indexes.

This commit is contained in:
Alexis Lahouze 2015-07-18 11:58:45 +02:00
parent ee17f7a12f
commit 744056a58d

View File

@ -25,26 +25,33 @@ from accountant import db
class Operation(db.Model): class Operation(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
operation_date = db.Column(db.Date, nullable=False) operation_date = db.Column(
db.Date,
nullable=False,
default=arrow.now().date(),
server_default=func.current_date(),
index=True
)
label = db.Column(db.String(500), nullable=False) label = db.Column(db.String(500), nullable=False)
value = db.Column(db.Numeric(15, 2), nullable=False) value = db.Column(db.Numeric(15, 2), nullable=False)
scheduled_operation_id = db.Column( scheduled_operation_id = db.Column(
db.Integer, db.Integer,
db.ForeignKey('scheduled_operation.id') db.ForeignKey('scheduled_operation.id'),
index=True
) )
scheduled_operation = db.relationship( scheduled_operation = db.relationship(
"ScheduledOperation", backref=db.backref('entry', lazy="dynamic") "ScheduledOperation", backref=db.backref('entry', lazy="dynamic")
) )
account_id = db.Column(db.Integer, db.ForeignKey('account.id')) account_id = db.Column(db.Integer, db.ForeignKey('account.id'), index=True)
account = db.relationship( account = db.relationship(
'Account', backref=db.backref('operation', lazy="dynamic") 'Account', backref=db.backref('operation', lazy="dynamic")
) )
category = db.Column(db.String(100), nullable=True) category = db.Column(db.String(100), nullable=True, index=True)
pointed = db.Column( pointed = db.Column(
db.Boolean, db.Boolean,