Commit Graph

496 Commits

Author SHA1 Message Date
Pea (Malgorzata Tyczynska)
ea28b65871 Merge pull request #1999 from alphagov/drop_monthly_billing_table
Drop monthly billing table
2018-07-31 16:35:48 +01:00
Rebecca Law
cc36209564 Fix file name for migration script 2018-07-31 14:00:18 +01:00
Rebecca Law
7378232353 Added migration script 2018-07-31 13:54:37 +01:00
Pea Tyczynska
885ed1e8e3 Remove monthly_billing table from the database 2018-07-31 11:47:13 +01:00
Rebecca Law
2b0ec9353e Added missing migration file 2018-07-25 14:16:36 +01:00
Alexey Bezhan
778909b189 Add callback_type to service callback history records
We've updated the current service callbacks to add callback types
in #1964, but since the table is versioned we also need to add a
type to the history records.

Even though they're not used anywhere at the moment this might make
it easier to restore from a history callback record in the future.
2018-07-18 13:57:42 +01:00
Pea Tyczynska
e81c395ab1 Assign delivery_status type to existing callbacks 2018-07-18 11:36:39 +01:00
Pea Tyczynska
183aa160c6 Add callback_type column to service_callback_api table
Also add service_callback_type table with allowed types
2018-07-17 16:54:00 +01:00
Rebecca Law
e4cc90e585 Fix merge conflict 2018-07-11 10:09:33 +01:00
Rebecca Law
df0df55402 Added unique constraint for service_id + notification_type
Change updated_at to have onupdate rather than default.
2018-07-11 10:09:33 +01:00
Rebecca Law
b71f6777e9 Create a table SERVICE_DATA_RETENTION to store the number of days the notification is to be kept for. 2018-07-11 10:09:33 +01:00
Rebecca Law
526831504d Merge branch 'master' of github.com:alphagov/notifications-api 2018-07-10 15:46:49 +01:00
Rebecca Law
1c54ef090d Clean up old, incomplete jobs 2018-07-10 15:39:51 +01:00
Rebecca Law
57d684bd0f Revert "Clean up old, incomplete jobs" 2018-07-10 15:37:39 +01:00
Rebecca Law
c1699cd0a5 Merge pull request #1936 from alphagov/fix-old-incomplete-jobs
Clean up old, incomplete jobs
2018-07-10 15:35:23 +01:00
Katie Smith
8f211e00f5 Migration for new letter pricing
We now support letters of up to 5 sheets long, so we need to store the
rates for 4 and 5 sheet letters (both crown and non-crown) in the
`letter_rates` table.
2018-07-10 09:34:42 +01:00
Chris Hill-Scott
d5469a9772 Clean up old, incomplete jobs
We have a few old jobs which don’t have a `processing_started` date.
This means that they always sort to the top of the jobs list in admin,
no matter how old they are. We think this is due to an old bug where
jobs would not be updated if a deploy was in progress.

This commit backfills the `processing_started` data for these jobs,
which will be roughly accurate. Complete accuracy is not the goal;
having these jobs not sort to the top of the list is.

This will affect 5 jobs across 3 services on production:
```sql
select service_id, job_status, created_at, updated_at, processing_started, processing_finished, notification_count, notifications_sent, notifications_delivered, notifications_failed from jobs where processing_started is null and job_status = 'in progress';
```

```
service_id              | job_status  |         created_at         |         updated_at         | processing_started | processing_finished | notification_count | notifications_sent | notifications_delivered | notifications_failed
--------------------------------------+-------------+----------------------------+----------------------------+--------------------+---------------------+--------------------+--------------------+-------------------------+----------------------
d47e5a1b-a04b-4398-8935-c8a266ce1d44 | in progress | 2017-09-29 13:49:41.512356 | 2017-10-01 02:01:05.281162 |                    |                     |              10615 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-09-29 09:25:39.802623 | 2017-09-29 16:01:02.154291 |                    |                     |              10240 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-09-29 09:31:52.455919 | 2017-09-29 16:01:01.990054 |                    |                     |               9930 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-08-22 08:15:39.125999 | 2017-08-22 16:01:07.758805 |                    |                     |               6967 |                  0 |                       0 |                    0
95316ff0-e555-462d-a6e7-95d26fbfd091 | in progress | 2016-05-27 14:44:18.114564 | 2016-06-13 00:18:14.542795 |                    |                     |               2742 |               2238 |                     525 |                 1713
(5 rows)
```
2018-07-09 11:33:15 +01:00
Chris Hill-Scott
8ceca4a068 Add letter organisation for Hackney Council 2018-07-05 15:50:38 +01:00
Chris Hill-Scott
1c960272a6 Add Ofgem letter logo 2018-06-29 10:09:18 +01:00
Chris Hill-Scott
ea06316807 Add letter logo for HM Passport Office
`009` matches the ID defined in
https://github.com/alphagov/notifications-template-preview/pull/143
2018-06-15 14:06:16 +01:00
Chris Hill-Scott
234c5c705a Add ‘caseworking’ service permission
We want to add the option for a user to have a more restricted view of
Notify.

This should be opt in/out on a per service basis, because it will be
appropriate only for a minority of teams. It shouldn’t be the default
because most teams (those without a lot of users or those only using the
API) won’t need it.

So this commit adds it as a new service permission, which means we can
roll it out:
- in prototype form initially
- then as an opt-in service setting
2018-06-11 13:23:06 +01:00
Richard Chapman
2daaa5e19c Rebase of master and increment filename for as there was already a 196
migration script.
2018-05-31 16:30:14 +01:00
Richard Chapman
aaba157587 Added Service contact_link column
This is going to be used for for the document download citizen landing
page, a service will add a contact link
e.g. https://customerservicecontactnumber.uk/dwp/ which will allow the
user to contact the sending department if there is an error or any
issues with the download.

* Added the contact link to the model
* Added db migration script to add the column to the database
2018-05-31 16:03:12 +01:00
Rebecca Law
1faba916b2 New complaints model to persist complaints from SES.
If a someone gets an email from one of our services and then complain about it (mark as spam or otherwise), we get a callback from SES.
The service needs to know about these complaints so they can remove that email from their mailing list.
2018-05-31 14:43:49 +01:00
Katie Smith
4d27972c90 Add created_at and updated_at columns to ft_notification_status
Added created_at and updated_at to the ft_notification_status table in order
to make it easier to track down any potential issues with the data.

Also updated the command to populate the data to take created_at and
updated_at into account and to simplify the command. This can all be done in
the same commit since the table is not being used anywhere yet and can
only be populated manually.
2018-05-24 10:51:38 +01:00
Katie Smith
c6c118fea1 Update created_at column of ft_billing to be non-nullable
`created_at` was added previously and made nullable temporarily. This
commit now populates the column, ensures that it will always have a
value, and makes `created_at` non-nullable.
2018-05-23 11:09:13 +01:00
Katie Smith
f6039d51e0 Add timestamp columns to ft_billing table
Added `created_at` and `updated_at` to the `ft_billing` table - having these
columns makes it easier to track down issues with the data in this table.

`created_at` is nullable initially, but will be changed to non-nullable
once the column is populated and the DAO etc. have been updated.
2018-05-22 14:32:49 +01:00
Katie Smith
3d8ce39984 Migration to drop unused provider_statistics table 2018-05-22 08:57:13 +01:00
Rebecca Law
e5584348ef Add rate to the primary key of ft_billing.
Use the primary key constraint in the upsert statement (easier to read than listing all the columns)
2018-05-21 14:38:25 +01:00
Chris Hill-Scott
f6b8611b18 Add letter logos for TWFRS and Thames Valley Police 2018-05-16 11:00:05 +01:00
Rebecca Law
56d7a7242b Fix merge conflict in db migration 2018-05-14 09:49:24 +01:00
Rebecca Law
2ae4cf18e8 Merge branch 'use-ft-billing-for-usage' of github.com:alphagov/notifications-api 2018-05-14 09:16:40 +01:00
Katie Smith
bb9eb367b7 Migration to create the ft_notification_status table
Added the migration for the `ft_notification_status` table which will be
used to look up the counts for notifications by various different
fields.

The `job_id` column is non-nullable because we want to include it in the
composite primary key. For notifications which weren't part of a job,
the `job_id` will be set to `0000-00000-0000-00000` when populating the
data.
2018-05-14 08:51:32 +01:00
Rebecca Law
d50a0d4cb4 Migration script
Change to command.
2018-05-10 16:41:24 +01:00
Chris Hill-Scott
545127966b Add letter organisation for CADW 2018-05-03 11:50:53 +01:00
Katie Smith
24f6ebb421 Change 'is_active' column names to 'archived'
Changed the name of the `is_active` columns to `archived` in these
tables:
* `service_email_reply_to`
* `service_sms_senders`
* `service_letter_contacts`

These columns were not being used yet, but because we describe Templates as
'archived', this keeps the names consistent.

The default value of these columns now needs to be False, not True.
2018-04-30 11:21:28 +01:00
Katie Smith
c401314072 Add is_active column for the 3 reply_to tables
Added a new boolean column, `is_active` to these tables
* service_email_reply_to
* service_sms_senders
* service_letter_contacts

This has a database default of True in order to backfill the data, but
this default will be replaced with a model default later.
2018-04-17 16:23:46 +01:00
venusbb
3ec68435ff add international as a composite primary key for billing 2018-03-28 16:09:06 +01:00
venusbb
2262db4f62 Database tweak and BST bug fix 2018-03-27 10:37:56 +01:00
Alexey Bezhan
04a643a777 Add a service permission for uploading documents to Document Download
Service permission allows attaching a file to a notification API request
that gets uploaded to Document Download API.
2018-03-27 10:16:56 +01:00
venusbb
af975b89ec primary key for ft_billing should use notification_type 2018-03-21 15:02:08 +00:00
Chris Hill-Scott
80fd2d73f7 Add Rother District Council logo for letters 2018-03-20 11:12:15 +00:00
venusbb
7e2947790f merged master and up migration version 2018-03-16 10:57:23 +00:00
Rebecca Law
8a11db7b2c Handle duplicate calls to update_letter_notifications_statuses
As it turns out the SNS topic is trigger more that once when a file is placed in S3, this is caused by a bug in the s3ftp software used to mount the S3 bucket to the FTP server.
S3ftp performs the create file operation more than once. This is resulting in duplicate counts of DailySortedLetter (the counts of how many letters marked as sorted or unsorted, which affect how much the provider will charge Notify for the letter).

This PR adds a new column to DailySortedLetter called file_name. A new unique constraint on billing_day + file_name is added. Each time we write a row to the table the counts are over written rather than aggregated.

I am aware that this PR is not backwards compatiable. However, since the code is typically triggered once a day around 13:00 then it is very unlikely an exception will occur during the deploy. Also a complete migration of the data based on all our response files on S3 will be performed soon, meaning the data will be corrected. Also if an exception does occur it is after the updates to notification status has already occurred.
2018-03-15 10:49:18 +00:00
venusbb
ea70c6454a Fine-tuning DB model and create taks for data migration
- Removed unused columns in ft_billing
- Create tasks for nightly data migration
2018-03-14 17:07:33 +00:00
Rebecca Law
82cc6d6bef As it turns out the s3ftp used to mount the s3 bucket to our ftp server puts the file on s3 more than once. So the SNS topic is triggered more than once.
We need to deal with this, it's ok when updating a notification status from delivered to delivered. But the DailySortedLetter counts are being doubled.
Adding the file_name to the table as a unique key to get around this issue. It will mean we have multiple rows for each billing_day, but that's ok we can aggregate that.
This will also give us a way to see which file created which count.
2018-03-14 17:04:58 +00:00
Katie Smith
7b05ce75c0 Fix revision numbers in migration 0177 2018-03-13 13:26:20 +00:00
Katie Smith
43c63a1644 Add new virus scan statuses
Added the following new notification statuses:
* pending_virus_check
* virus_scan_failed

If we decide to remove these statuses in future, we will need to replace
them with a different status in the notifications and
Notification_history tables where they are referenced, so
pending-virus-check will be replaced with sending, and virus-scan-failed
will be replaced with permanent-failure.
2018-03-13 12:03:14 +00:00
venusbb
59898b7349 Add billing models and small alteration to billing tables 2018-03-12 18:19:26 +00:00
Katie Smith
cae38c5d54 Migration to drop job_statistics table 2018-03-12 12:38:06 +00:00