Commit Graph

188 Commits

Author SHA1 Message Date
Rebecca Law
31de10ae6f dB script to default templates/templates_history.process_type = 'normal' and set the column to not null 2017-01-16 11:19:46 +00:00
Rebecca Law
ceb139ca28 Fix foreign key names 2017-01-13 12:29:13 +00:00
Rebecca Law
6c79ddbe41 This is the first deploy in series of deploys to give certain templates priority in processing.
If the template is marked as priority the notification will be sent using the `notify` queue.
The `notify` queue is a low volume queue, messages here will not be queue behind a large job and should be delivered with in a more consistent time frame.

- Added templates.process_type and templates_history.process_type column.
- Added a template_process_type table to handle the enum for templates.process_type, initial values are normal and priority

https://www.pivotaltracker.com/story/show/135429147
2017-01-13 12:14:34 +00:00
Leo Hemsted
f1899c6d53 add updated_at to provider_details
it's set to utcnow from dao_update_provider_details
2016-12-19 17:45:46 +00:00
Leo Hemsted
74cdcdcc92 set prov details history's primary key to be id+version 2016-12-19 17:33:51 +00:00
Leo Hemsted
9d1b1328af add version to provider_details and _history
set all existing rows to have a version of 1 (also copy across values
to populate the new provider_details_history table in the upgrade
script)

in dao_update_provider_details bump the provider_details.version by 1
and then duplicate into the history table as a new row
(done manually as opposed to the decorator used in template_history
since this is only edited in this one place and the decorator is icky)
2016-12-19 17:13:10 +00:00
Leo Hemsted
a197754906 add new provider_details_history table
* to be used for auditing changes to provider details
* not hooked in yet
* also made provider_details.active non-nullable. set all existing null
  provider_details.active to FALSE. none are set false on live so
  should hopefully be fairly uncontroversial
* refactored NotificationHistory.from_notification and update from noti
  to share with provider_details_history
2016-12-19 17:13:10 +00:00
Rebecca Law
bc434f1736 Create new column in notifications and notification_history to store the client_reference because I remembered that reference is used for email providers. 2016-11-17 13:42:34 +00:00
Chris Hill-Scott
35e1e06db4 Fix conflicting migration versions
Two different versions of 0059 were merged.

`0059_set_services_to_active` was merged first, so this renames my
migration to `0060`, so it goes in afterwards.
2016-11-11 16:30:05 +00:00
Chris Hill-Scott
7ada78a0b6 Merge pull request #731 from alphagov/letter-templates-db
Add letter to possible template types in DB
2016-11-11 17:13:33 +01:00
Chris Hill-Scott
6501a871bc Add letter to possible template types in DB
A letter type was added to the `enum` in the `Template` model at the
same it was added to the `Notification` model. But the migration was
only done for the `notifications` table, not the `templates` table.

See: https://github.com/alphagov/notifications-api/commit/25db1bce#diff-516aab258e161fc65e7564dabd2c625aR19

This commit does the migration to add `letter` as a possible value for
the `template_type` column, which is a bit fiddly because `enum`s.

Before:
```
notification_api=# select enum_range(null::template_type);
 enum_range
-------------
 {sms,email}
(1 row)
```

After upgrade:
```
notification_api=# select enum_range(null::template_type);
     enum_range
--------------------
 {sms,email,letter}
(1 row)
```

After downgrade
```
notification_api=# select enum_range(null::template_type);
 enum_range
-------------
 {sms,email}
(1 row)
```
2016-11-11 10:41:09 +00:00
Leo Hemsted
da2fa5b4bc move sqlalchemy defaults from booleans to SQL constructs
booleans aren't actually allowed, and quietly do nothing

also default Services.active to true
2016-11-08 17:10:28 +00:00
Leo Hemsted
a45c62d41d add can_send_letters flag to services
defaults to false
2016-10-26 13:01:40 +01:00
Rebecca Law
c17f0b9b91 Confirm new email address template.
Creation of a new template for the GOV.UK Notify service to send to users to confirm the change of their email address.
2016-10-11 13:28:46 +01:00
Rebecca Law
6f83258004 Update Template.version and TemplateHistory.version nullable=False to match the db 2016-10-04 10:47:34 +01:00
Rebecca Law
81a390f9c3 There are differences in the models to the database, this script
gets the database up to speed with the models.
2016-10-04 10:00:00 +01:00
Imdad Ahad
005e8a9c3a Change data model to use single recipient address and type columns 2016-09-27 13:43:42 +01:00
Leo Hemsted
3d0df9b5a7 add new service whitelist table
services can have a whitelist of phone numbers and email addresses that they
can send to in addition to team members when in trial mode. email_address
and mobile_number are nullable and app level checks will be in place to
prevent inserting blank rows. they have a created_at date so that we can
[potentially] delete them a week later to avoid keeping personally identifying
data any longer than necessary
2016-09-22 10:32:32 +01:00
Martyn Inglis
5f72034577 Renamed and fixed the migration script to be in sequence 2016-09-08 16:12:15 +01:00
Martyn Inglis
e099edae51 Merge branch 'master' into drop-status-column 2016-09-08 16:11:18 +01:00
Chris Hill-Scott
1bf37888dd Fix mis-matched database migrations
The cancelled job migration originally went in as version `0051`.

But `0051_set_job_status` went in first in
e3fa8bffd7

This meant that Alembic couldn’t work out what order to run the
migrations in, and blew up.

This commit puts the scheduled job migration after all others.
2016-09-06 13:07:20 +01:00
Chris Hill-Scott
be9fd96d03 Merge pull request #656 from alphagov/add-cancel-job-endpoint
Add an endpoint to cancel a job
2016-09-06 12:11:32 +01:00
Martyn Inglis
cf3ca764c5 Drop the status column 2016-09-05 16:16:32 +01:00
Martyn Inglis
22844d1bf2 Changed 0052 to not drop the column, rather set it to allow nulls.
This allows existing code to run.
2016-09-05 13:22:45 +01:00
Chris Hill-Scott
4a7267be8b Add an endpoint to cancel a job
If you schedule a job you might change your mind or circumstances might
change. So you need to be able to cancel it. This commit adds a `POST`
endpoint for individual jobs which sets their status to `cancelled`.

This also means adding a new status of `cancelled`, so there’s a
migration…
2016-09-02 12:27:02 +01:00
Rebecca Law
e3fa8bffd7 Fix merge conflicts in tests.
Update new migrations scripts to fix conflict in with script names.
2016-09-02 12:01:38 +01:00
Rebecca Law
8f3e8181fe Merge branch 'master' into scheduled-delivery-of-jobs-cleanup
Conflicts:
	tests/app/job/test_rest.py
2016-09-02 11:03:21 +01:00
Martyn Inglis
ab5ff64dd0 Indexes to improves stats for service query 2016-08-31 16:24:18 +01:00
Martyn Inglis
489f95c8cd Fixed the downgrade script 2016-08-31 10:23:34 +01:00
Martyn Inglis
6488feaeec Remove the status column from jobs, and update the new job status column with the previous values 2016-08-31 10:23:34 +01:00
Martyn Inglis
805da23d6b Starting to implement scheduling 2016-08-24 14:04:52 +01:00
Martyn Inglis
5adecda41e Adds new job_status table and FK to jobs.
This will replace the job_status enum type.
2016-08-24 13:34:42 +01:00
Leo Hemsted
d7945d85dc update ukvi org branding spelling
was previously UK Visas and Immigration
now UK Visas & Immigration
2016-08-22 16:12:09 +01:00
Leo Hemsted
d38fdb2d11 add organisation and branding models
a service now has branding and organisation_id columns, and two new
tables have been aded to reflect these:
* branding is a static types table referring to how a service wants
  their emails to be branded:
    * 'govuk' for GOV UK branding (default)
    * 'org' for organisational branding only
    * 'both' for co-branded output with both
* organisation is a table defining an organisation's branding. this
  contains three entries, all of which are nullable
    * colour - a hex code for a coloured bar on the logo's left
    * logo - relative path for that org's logo image
    * name - the name to display on the right of the logo
2016-08-09 16:03:04 +01:00
Leo Hemsted
c7d909be03 add UKVI as first organisation branding 2016-08-09 15:59:22 +01:00
Leo Hemsted
a6cd490942 add organisation and branding models
a service now has branding and organisation_id columns, and two new
tables have been aded to reflect these:
* branding is a static types table referring to how a service wants
  their emails to be branded:
    * 'govuk' for GOV UK branding (default)
    * 'org' for organisational branding only
    * 'both' for co-branded output with both
* organisation is a table defining an organisation's branding. this
  contains three entries, all of which are nullable
    * colour - a hex code for a coloured bar on the logo's left
    * logo - relative path for that org's logo image
    * name - the name to display on the right of the logo
2016-08-09 15:59:16 +01:00
Leo Hemsted
d86af3ce83 fix syntax errors in downgrade script 2016-08-04 12:00:26 +01:00
Leo Hemsted
527a5c4eaa calculate billable units when sending an sms
don't calculate it if we're in research mode
* added tests to prove this
* removed last code referring to content_char_count
2016-08-03 16:46:05 +01:00
Leo Hemsted
2793541b9c add billable_units column to notifications table
this replaces content_char_count, by performing the additional
steps to calculated billable units at insert time, rather than
read time. This means we can take into account whether the
service was in research mode or using a test api key when the
notification was sent :tada
2016-08-03 16:41:06 +01:00
Martyn Inglis
daf85e7787 Reorder the SQL scripts as clash 2016-08-01 15:19:16 +01:00
minglis
54a63c0351 Merge pull request #544 from alphagov/job-notification-history
Create notification history from jobs
2016-08-01 15:04:15 +01:00
Martyn Inglis
cfb29d4404 Ensure the downgrade script targets only DMP services 2016-08-01 12:20:06 +01:00
Leo Hemsted
6edb9324da add indexes to notifications and notification_history 2016-08-01 11:34:20 +01:00
Adam Shimali
183fc7d639 After doing some tests locally. To get this to run in a reasonable
amount of time I've made the following changes.

Only migrate jobs for the Digital Marketplace service.

Batch up commits to run per job.
2016-07-26 16:23:36 +01:00
Adam Shimali
3b8a163ff2 Db migration to retrospectively create notification history from
jobs table.

The migration selects only jobs from after the go live date and before
the earliest record in notication history table.
2016-07-19 16:46:17 +01:00
Leo Hemsted
fb7e9dfcb3 copy existing notifications into history table 2016-07-12 13:45:19 +01:00
Leo Hemsted
4ef084464d update notification_history table from notification_dao create/update functions
please ensure that any changes to notifications table happen through either dao_create_notification or dao_update_notification.
changed the notification status update triggered by the provider callbacks to ensure that sets updated_by and can update the history table.
also re-added the character_count so we can reconstruct billing data if needed.
2016-07-12 13:28:45 +01:00
Leo Hemsted
722699a72a Update notification_history table on insert/update of notifications
triggered via calls in dao_create_notification and dao_update_notification - if you don't use those functions (eg update in bulk) you'll have to update the history table yourself!
2016-07-12 13:27:31 +01:00
Leo Hemsted
47ef63adbe add notification_history table
table will be used for storing archival versions of notifications. It's an exact duplicate of notifications table, but with the following modifications:
* removed _personalisation
* removed to
* removed content_char_count

All foreign keys to other tables still exist. additionally, removed defaults (for id and created_at) since they'll be set when we create, and we should ensure that we don't forget about them when inserting/udpating this table.
2016-07-12 13:27:31 +01:00
Rebecca Law
36ecdca04c Add new email template for the GOV.UK Notify service, to send an email to users that register with the same email address.
Add a new endpoint to send the email.
2016-07-07 17:23:07 +01:00