884 Commits

Author SHA1 Message Date
Rebecca Law
43c0122dd0 Fix db downgrade script 2019-11-06 13:54:16 +00:00
Rebecca Law
4da06f1d5d remove old db upgrade file 2019-11-06 11:17:01 +00:00
Rebecca Law
fd0c12912a Fix merge conflict with db upgrade 2019-11-06 10:54:38 +00:00
Rebecca Law
db5a50c5a7 Adding a scheduled task to processing missing rows from job
Sometimes a job finishes but has missed a row in the middle. It is a mystery why this is happening, it could be that the task to save the notifications has been dropped.
So until we solve the missing let's find missing rows and process them.

A new scheduled task has been added to find any "finished" jobs that do not have enough notifications created. If there are missing notifications the job processes those rows for the job.
Adding the new task to beat schedule will be done in the next commit.

A unique key constraint has been added to Notifications to ensure that the row is not added twice. Any index or constraint can affect performance, but this unique constraint should not affect it enough for us to notice.
2019-11-06 10:49:46 +00:00
Leo Hemsted
4ed6ca1601 remove loadtesting from the database 2019-11-05 15:01:55 +00:00
David McDonald
4bc71f36bf Delete dm_datetime database table
No longer needed
2019-10-08 14:02:43 +01:00
Leo Hemsted
ddfc722537 letter rates go up by 5p as of 1st october 2019 2019-09-25 16:33:53 +01:00
Chris Hill-Scott
edb5790b7c Use nhs_gp not gp as org type
Means we have the option of looking for anything starting with `nhs` as
a way of filtering organisations.
2019-08-28 15:24:30 +01:00
Chris Hill-Scott
a5b36457f2 Add ‘GP’ as an org type
Although their allowances are the same as what we call `nhs_local` it
makes more sense to store them separately because:
- we already present them as two separate choices to the user
- we may want to handle them differently in the future, eg in terms of
  what branding choices are available to them
2019-08-27 17:01:03 +01:00
Rebecca Law
b37de7785c Remove the organisation_to_service table.
This table is no longer used or referenced in the code.
We can remove this mapping table now that the organisation to service relationship is handled by the foreign key in Services.
2019-08-15 15:17:53 +01:00
Rebecca Law
c4127d0508 Improve the data migration and downgrade script. 2019-08-14 11:01:22 +01:00
Rebecca Law
55dc7184cc Add organisation_id to Service.
This is the second commit in the series to add organisation_id to Service.
- Data migration to update services.organisation_id from data in organisation_to_service
 (The rollback will lose any updates to organisation unless the script is updated to set organistion_to_service from service.organisation_id )
- Update Service.organisation relationship to a ForeignKey relationship to Organisation.
- Update Organisation.services to a backref relationship to Service.
2019-08-13 17:25:30 +01:00
Katie Smith
6ea849298e Merge pull request #2580 from alphagov/set-bad-email-addresses-to-perm-fail
Set bad email addresses to permanent-failure
2019-08-12 16:03:01 +01:00
Katie Smith
b31e431d4e Rename migration file to match migration revision ID
Because these were slightly different, the `check_if_new_migration`
script would always think there was a new migration to run and so we
were always testing the db migrations when deploying.
2019-08-09 12:41:19 +01:00
Katie Smith
f8035811a7 Add new 'upload_letters' permission 2019-08-05 12:02:43 +01:00
Pea Tyczynska
5977adef1c Add live to excluded environments in migration 2019-07-25 16:03:08 +01:00
Pea Tyczynska
38bb2c1cf6 Simpify org types migration script and introduce foreign key
Don't transform org types on prod
2019-07-24 17:55:56 +01:00
Pea Tyczynska
5b256fa64e Migrate all orgs and services onto new organisation types
Remove all mentions of generic 'nhs' organisation type.
2019-07-22 14:58:41 +01:00
Pea Tyczynska
edda816ffa Temporarily add generic 'nhs' 2019-07-19 15:13:24 +01:00
Pea Tyczynska
aa88252cf7 Drop making crown not nullable on downgrade as it would fail anyway 2019-07-18 17:05:24 +01:00
Pea Tyczynska
d89ef0594f nhs_central is crown org and also we do not update org type while
updating service anymore.
2019-07-18 17:05:24 +01:00
Pea Tyczynska
e4cb56b5d3 Emergency service instead of emergency services 2019-07-18 17:05:23 +01:00
Pea Tyczynska
8a3ac8400f Update service type and crown when service is added to organisation 2019-07-18 17:05:23 +01:00
Pea Tyczynska
9dfc550f46 Add org types table 2019-07-18 17:05:22 +01:00
Leo Hemsted
a61a28a8c8 add emails to send when an MOU is signed
* tell the user that clicks the button
* tell the notify team
* tell the person that the button was clicked on behalf of

there are two templates for the first case
2019-07-09 11:57:13 +01:00
Pea Tyczynska
2a5b0f8f17 Change the order of delete statements to respect foreign key constraint 2019-06-28 11:22:12 +01:00
Pea Tyczynska
9782b08982 Add comment reminder to add template redacted when creating a template
through a migration.
Also fix the downgrades so they delete everything that needs deleting.
2019-06-26 19:03:15 +01:00
Pea Tyczynska
bd3594b2a9 Resign from trigger solution as we couldn't make it work 2019-06-26 18:36:03 +01:00
Pea Tyczynska
32e45828f8 Rename migration file 2019-06-26 18:36:03 +01:00
Pea Tyczynska
ce6f1a5572 Add trigger that ensures row in template_redacted is created
when adding new template through a migration
2019-06-26 18:36:03 +01:00
Pea Tyczynska
0ca7d4a20c Create template_redacted entry for templates created by migration
So that we can edit those templates
2019-06-26 18:36:03 +01:00
Chris Hill-Scott
8977f5193e Add columns for on whose behalf agreement signed
This is changing because we’re going to introduce accepting contracts
and MoUs online.

Previously
---
We had one column for who signed the agreement, which is foreign keyed
to the user table. This is still relevant, because there will always be
a user who is clicking the button.

Now
---
We add two new fields for the name and email address of the person on
whose behalf the agreement is being accepted. This person:
- is different from the one signing the agreement
- won’t necessarily have a Notify account
2019-06-18 10:41:22 +01:00
Rebecca Law
a1f6a5f78a Update the unique constraint for the name of an api_key so that it only looks at api_keys that are not expired (or expiry_date is null).
This will allow clients to create a new api key with the same name.
2019-06-04 15:30:27 +01:00
Pea Tyczynska
c4d20667a6 Add notification deletion to downgrade to respect foreign key constraints 2019-05-28 15:25:06 +01:00
Pea Tyczynska
5f1f688c7b Create template to verify service email reply-to addresses
So that template with the same ID is present on all environments
2019-05-28 15:14:09 +01:00
Rebecca Law
3374e03ce9 Prepare to stop inserting NotificationHistory at the time of inserting a notificaiton.
Need to remove foreign key to complaints.
Make sure if getting Notification.id we look to both tables.
2019-05-21 16:08:18 +01:00
Pea Tyczynska
67e3a7689a Give existing users all folder permissions
This will be done just before we turn on folder permissions
to all services to ensure that all users start with all the
permissions.
2019-05-17 10:33:05 +01:00
Leo Hemsted
9d415cd292 remove unnecessary unique index
primary key provides the same control. also catch the right exception
in the related command
2019-05-16 14:36:17 +01:00
Katie Smith
84c35cbf67 Add request_to_go_live_notes column to Organisation table
This column will be used to stores extra notes that should go in the
Zendesk ticket when a service belonging to that organisation requests to
go live.
2019-05-13 14:45:01 +01:00
Pea Tyczynska
150e14de96 remove precompiled_letter permission from the database 2019-05-13 13:05:34 +01:00
Rebecca Law
55b2fd6d57 Fix the migration file conflicts 2019-04-17 13:39:49 +01:00
Rebecca Law
60b4970d7f Add new columns to services and services_history.
go_live_user_id: is the user that requested the service to go live
go_live_at: is the DateTime the service went live.

There will be a data migration from the beta partners spreadsheet to back fill the data.
2019-04-17 13:20:44 +01:00
Chris Hill-Scott
916d4e2860 Remove domain columns from branding table
This relationship is via the `Organisation` now; we don’t use this
column to fudge a relationship based on the user’s email address and the
matching something in these columns.
2019-04-15 16:14:41 +01:00
Rebecca Law
64428368d1 Update EmailBranding.name to be not null and unique.
Needed to update old migration scripts so that the email_branding name is not null when creating the test dbs.
This should no affect the migrations elsewhere.
2019-04-09 14:33:38 +01:00
Chris Hill-Scott
2ef9618e70 Set default branding for all organisations
Currently when someone creates a service we match them to an
organisation. Then if the organisation has a default branding set, their
service gets that branding.

However none of the organisations yet have a default branding set up.
This commit migrates the data about the relationship between an
organisation and its branding from being inferred from the `domain`
field on the branding, to being a proper database relationship.
2019-04-05 15:40:20 +01:00
Chris Hill-Scott
853314efe9 Retry making services created by platform admin users not counted in the list of live services
The previous migration didn’t work because the `created_by_id` column
in services references the user who created the _version_ of the
service, not who created the service originally.

This commit runs another migration to wipe all the data, and replace it
using an operation that looks at the first version of the service in the
history table, which will reference the user who actually created the
service.
2019-03-25 17:31:52 +00:00
Chris Hill-Scott
1f12da3d04 Migrate existing platform admin services to not be counted
If a service has been created by someone on our team, it’s probably a
test service, which shouldn’t be included in the count of live services.

This commit adds a migration to do this for existing services.
2019-03-25 13:30:54 +00:00
Chris Hill-Scott
b3008ee210 Allow excluding services from live services count
Sometimes we have to make a few services for what really is one
service, for example GOV.UK Pay and GOV.UK Pay Direct Debit. We also
have our own test services which aren’t included in the count of live
services. We currently count these as one service by not including them
in the beta partners spreadsheet.

This adds a column to mark such services as ‘not counted’, which can
later be used to exclude them from reporting.
2019-03-25 13:28:31 +00:00
Katie Smith
8f5b5d636e Make invited_users folder_permissions column non-nullable
Now that notifications-admin is always sending through
folder_permissions, the folder_permissions column of the invited_user
table can be made non-nullable. The migration also backfills the column
(to []) to account for existing null values.
2019-03-22 10:49:45 +00:00
Katie Smith
3e70407981 Migration to add folder_permissions to invited_users table
Added a new JSONB column, folder_permissions, to the invited_users table
to store a list of folders that an invited user can see. This is
nullable for now, but will be changed to be non-nullable and
back-populated later.
2019-03-22 09:30:39 +00:00