From 744056a58d42364fc78c91fa6c762da717345468 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sat, 18 Jul 2015 11:58:45 +0200 Subject: [PATCH] Add some indexes. --- accountant/api/models/operations.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/accountant/api/models/operations.py b/accountant/api/models/operations.py index 9542c88..88337c3 100644 --- a/accountant/api/models/operations.py +++ b/accountant/api/models/operations.py @@ -25,26 +25,33 @@ from accountant import db class Operation(db.Model): 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) value = db.Column(db.Numeric(15, 2), nullable=False) scheduled_operation_id = db.Column( db.Integer, - db.ForeignKey('scheduled_operation.id') + db.ForeignKey('scheduled_operation.id'), + index=True ) scheduled_operation = db.relationship( "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', 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( db.Boolean,