Commit Graph

466 Commits

Author SHA1 Message Date
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
venusbb
01ff06fc09 Rename tables, column and added indexes 2018-03-09 08:17:02 +00:00
venusbb
a4c054124f work in progress 2018-03-07 17:23:52 +00:00
venusbb
5082d9d83c Increase datetime number of years from 20 to 50 2018-03-07 12:57:19 +00:00
venusbb
effaecbd49 added ft_billing and dm_datetime tables for report purpose 2018-03-07 12:46:11 +00:00
Katie Smith
b0de3ba4d9 Create DailySortedLetter table
The response files we receive from the DVLA when we send letters
contain a row for each letter and a field with a value of 'Unsorted' or
'Sorted'. This table will be used to store the total number of
'Unsorted' and 'Sorted' letter notifications per day.
2018-03-06 09:09:02 +00:00
Chris Hill-Scott
08027947b2 Remove priority flag from example templates
Since we send all one off messages as priority
[now](https://github.com/alphagov/notifications-api/pull/1722), we don’t
need to explicitly mark the ‘Example text message template’ template as
being priority.

This commit retroactively removes the priority flag from these
templates, so that they can’t be reused to send other messages as
priority. I don’t think this is a real problem now, but worth cleaning
this up.

This query will hit approximately 827 templates.
2018-03-01 09:37:14 +00:00
Rebecca Law
0728c9f41a Fix db migration conflicts 2018-02-26 16:48:12 +00:00
Rebecca Law
7faf375375 Merge pull request #1695 from alphagov/org-user-endpoints
Organisation user endpoints
2018-02-26 16:27:01 +00:00
Alexey Bezhan
dc99fe5ff3 Set Templates.hidden column as non-nullable
Sets hidden to false for all existing templates and makes column
non-nullable.
2018-02-26 13:28:08 +00:00
Alexey Bezhan
3a15a7e783 Set Template.hidden as nullable before the new app code gets released
Since the application code gets released after the migration setting
a new Template field as non-nullable prevents new templates from being
created by the existing application instances.

This splits the migration to set fields as nullable first and then
update existing records once the application code has been released.

0168 is modified not to run UPDATE query or set non-nullable flag in
staging and production. 0169 is added to rollback preview.
2018-02-26 10:46:20 +00:00
Alexey Bezhan
6d1439e39a Add a DB migration to create Templates.hidden column
Creates the column as nullable, sets the value to false for all
existing templates and template versions and then applies a
not-nullable constraint.

All future Templates are created with `False` as the default set
in SQLAlchemy.
2018-02-23 17:52:24 +00:00
Rebecca Law
7c44171a40 Fix merge conflict in db migration script 2018-02-23 10:57:24 +00:00
Leo Hemsted
5b71d2f36e add org invite template to db 2018-02-23 10:45:18 +00:00
Ken Tsang
90e9d99161 Add precompiled_letter service permission
- migration script to add precompiled_letter in service_permission_types table and in service permission types list in models.py
2018-02-21 16:26:49 +00:00
Leo Hemsted
450deae32a add user_to_organisation and invited_organisation_users tables
similar to user_to_service and invited_users, but without auth types
or permissions
2018-02-15 14:19:24 +00:00
Leo Hemsted
15e31fd6e6 add sms sender to old script
we have problems where govuk service is not migrated to sms_senders on new datbases.
update this old script so we don't affect live systems, but when people rebuild their
database from scratch they get the sms sender for govuk notify.
2018-02-15 14:18:22 +00:00
Chris Hill-Scott
f4be8fd80b Add East Riding of Yorkshire Council to migration 2018-02-15 11:08:17 +00:00
Chris Hill-Scott
f55f555e4d Add letter logo for Welsh Revenue Authority
Depends on:
- [ ] https://github.com/alphagov/notifications-template-preview/pull/94
2018-02-15 11:08:16 +00:00
Rebecca Law
4820365b13 Rename migration file so that the force db migration part of the deploy does not trigger 2018-02-15 09:47:28 +00:00
Ken Tsang
6e0e3e9f08 Migration script to add organisation_to_service association table 2018-02-13 14:06:43 +00:00
Katie Smith
d40d520d2c Add Organisation model and migration
Now that we have renamed the 'old' organisation model to email_branding,
we can create a new organisation model.
2018-02-08 14:39:25 +00:00
Leo Hemsted
37dda1d235 remove organisation from db
also make sure email branding is not nullable, because it shouldnt be
2018-02-08 11:26:10 +00:00
Leo Hemsted
6e9edc3e8a add email branding mapping table 2018-02-02 11:48:58 +00:00
Chris Hill-Scott
f0f3e03931 Add letter logo for environment agency
Depends on:
https://github.com/alphagov/notifications-template-preview/pull/87
2018-01-29 17:29:24 +00:00
Chris Hill-Scott
d70fc958f6 Backfill redaction for pre-seeded templates
Will specifically affect the email auth template, which was seeded
without a matching row in the `template_redacted` table.

Effectively re-runs c24edcf388

> add historical redaction data
>
> every current template gets a row in the template_redacted table -
> this inserts one for any template that doesn't already have a row,
> with redact set to false, the user set to NOTIFY_USER since it was
> just a script, and the updated_at set to the time the script is run
2018-01-18 12:38:43 +00:00
Katie Smith
f6ef0ebbd7 Remove database default on rate_limit column
The default for the rate_limit column in the services and
services_history model is now set in the model, so we can remove the
default from the database.

Pivotal story: https://www.pivotaltracker.com/story/show/153992529
2018-01-11 10:37:26 +00:00
Katie Smith
649679d67f Add rate_limit column to service model
The API rate limit will be removed from the config and added to services
so that it is possible to change the rate_limit for individual services
in rare cases.

Pivotal story: https://www.pivotaltracker.com/story/show/153992529
2018-01-09 11:20:52 +00:00
Rebecca Law
7792c18efb Migration script to update the templates and templates_history (latest version only) with the service default letter contact block. 2018-01-05 17:34:51 +00:00
Rebecca Law
884b8f3990 Merge branch 'master' into revert-is_letter_contact_blank 2018-01-05 16:20:50 +00:00
Rebecca Law
f34a380f7f Fix file name 2018-01-05 16:00:29 +00:00