From 335aeb386fe8c15da9bfcc053b9d105ba1a159cd Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Mon, 24 Sep 2018 14:20:39 +0100 Subject: [PATCH] Update FactBilling model to reflect current database state The FactBilling model and the ft_billing database table have diverged slightly - this makes some minor changes to the model columns so that the model matches the table (which appears to be the correct version). The ft_billing table is currently like this: Column | Type | Modifiers | Storage | Stats target | Description --------------------+-----------------------------+-----------+----------+--------------+------------- bst_date | date | not null | plain | | template_id | uuid | not null | plain | | service_id | uuid | not null | plain | | notification_type | text | not null | extended | | provider | text | not null | extended | | rate_multiplier | integer | not null | plain | | international | boolean | not null | plain | | rate | numeric | not null | main | | billable_units | integer | | plain | | notifications_sent | integer | | plain | | updated_at | timestamp without time zone | | plain | | created_at | timestamp without time zone | not null | plain | | Indexes: "ft_billing_pkey" PRIMARY KEY, btree (bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate) "ix_ft_billing_bst_date" btree (bst_date) "ix_ft_billing_service_id" btree (service_id) "ix_ft_billing_template_id" btree (template_id) --- app/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models.py b/app/models.py index 5df7730bf..9fdca45de 100644 --- a/app/models.py +++ b/app/models.py @@ -1805,12 +1805,12 @@ class FactBilling(db.Model): bst_date = db.Column(db.Date, nullable=False, primary_key=True, index=True) template_id = db.Column(UUID(as_uuid=True), nullable=False, primary_key=True, index=True) - service_id = db.Column(UUID(as_uuid=True), nullable=False, index=True) + service_id = db.Column(UUID(as_uuid=True), nullable=False, primary_key=True, index=True) notification_type = db.Column(db.Text, nullable=False, primary_key=True) - provider = db.Column(db.Text, nullable=True, primary_key=True) - rate_multiplier = db.Column(db.Integer(), nullable=True, primary_key=True) - international = db.Column(db.Boolean, nullable=False, primary_key=False) - rate = db.Column(db.Numeric(), nullable=False) + provider = db.Column(db.Text, nullable=False, primary_key=True) + rate_multiplier = db.Column(db.Integer(), nullable=False, primary_key=True) + international = db.Column(db.Boolean, nullable=False, primary_key=True) + rate = db.Column(db.Numeric(), nullable=False, primary_key=True) billable_units = db.Column(db.Integer(), nullable=True) notifications_sent = db.Column(db.Integer(), nullable=True) created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)