Commit Graph

601 Commits

Author SHA1 Message Date
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
Rebecca Law
2cbcf2b805 Fix merge conflicts 2019-03-11 11:43:16 +00:00
Rebecca Law
d43a274562 Merge branch 'master' into remove-fk-to-users 2019-03-11 11:25:17 +00:00
Chris Hill-Scott
98b389baa2 Fix organisation domain migration
Have to drop constraint before dropping columns.
2019-03-08 15:03:00 +00:00
Chris Hill-Scott
d7e03e00d3 Storing more info about an organisation
Currently we have
- a thing in the database called an ‘organisation’ which we don’t use
- the idea of an organisation which we derive from the user’s email
  address and is used to set the default branding for their service and
  determine whether they’ve signed the MOU

We should make these two things into one thing, by storing everything
we know about an organisation against that organisation in the database.
This will be much less laborious than storing it in a YAML file that
needs a deploy every time it’s updated.

An organisation can now have:
- domains which we can use to automatically associate services with it
  (eg anyone whose email address ends in `dwp.gsi.gov.uk` gets services
  they create associated to the DWP organisation)
- default letter branding for any new services
- default email branding for any new services
2019-03-08 13:30:32 +00:00
Rebecca Law
06facb7576 Removing the foreign from to users from Notification_history.
The relationship is not used and it prevents us from deleting users. It would be good to delete users that are never activated.
2019-03-07 17:20:42 +00:00
Chris Hill-Scott
b27bcc1d80 Make consent_to_research nullable
It should be nullable so we can tell whether someone has answered the
question already or not.

No real users have entered data into this column yet, so it’s fine to
wipe it.
2019-03-01 15:21:49 +00:00
Katie Smith
33166f3fb2 Add migration for user_folder_permissions table
Changed the user_to_service mapping table into a model called
ServiceUser. When looking at users who have permission for a folder
we are only interested in users for a particular service, not all users,
so we can use the ServiceUser model to access folder permissions.

Added a user_folder_permissions table which contains the service_id,
user_id and template_folder_id. There are links between
user_folder_permissions and TemplateFolder, and between
user_folder_permissions and ServiceUser.
2019-02-27 11:50:36 +00:00
Pea Tyczynska
211d3741ba Send confirmation emails to users when team manager edits their
email address  or mobile number.
2019-02-26 16:30:29 +00:00
Alexey Bezhan
1d77310fbd Add folder permissions permission
[#163755302](https://www.pivotaltracker.com/story/show/163755302)

Adds a new temporary service permission for enabling folder permission
editing.
2019-02-19 10:23:40 +00:00
Rebecca Law
34e5e9558d Last commit to remove edit_folders. 2019-02-15 14:44:33 +00:00
Rebecca Law
718626f639 Remove all edit_folder permissions from service_permissions 2019-02-15 14:35:34 +00:00
Chris Hill-Scott
7ca62ce4cf Bump migration version 2019-02-15 10:09:44 +00:00
Chris Hill-Scott
f679731af8 Also store consent to research against a service
It makes most sense to collect this at the same time as the estimated
volumes. Which means we need to store it somewhere; we can’t put it
straight into the ticket.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
ecdf076506 Store anticipated volumes as integers
This will make it easier to do analysis on the data. Almost all users
are submitting data in a numerical format now anyway, because we ask the
question in a sensible way.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
17e32fa5f6 Add fields to record a service’s estimated volumes
When a service go live we ask people for their estimated sending
volumes. At the moment we only put this in the ticket, and store it in
a spreadsheet.

This means that a service can
- say they want to go live
- say they are sending 100,000 emails per year
- not have created any email templates
- still see ‘create templates’ as ‘completed’ in the go live checklist

If we store this data against the service we can collect it earlier, and
then use it to determine automatically what kind of templates the user
needs to create before their go live checklist can be considered
complete.
2019-02-15 10:08:22 +00:00
Leo Hemsted
06f9e445f7 remove dvla_organisation from database
downgrade re-populates all static data but leaves all services with 001
(HM Government) branding
2019-02-14 14:27:59 +00:00
Rebecca Law
4ce5724bc7 Fix the downgrade of the migration.
By the way I'm not concerned about fixing service.postage data if we have to rollback.
2019-02-13 15:40:08 +00:00
Pea Tyczynska
97b1e034b8 Remove service.postage and choose_postage permission from database
Also change constraint on template postage so it cannot be null for
letters

Also add postage to all letters in template_history to respect new constraint
2019-02-13 11:50:00 +00:00
Pea Tyczynska
6320882876 Make service postage nullable 2019-02-12 12:15:38 +00:00
Rebecca Law
429997e778 Data migration to populate letter_branding and service_letter_branding.
Only service_letter_branding is added where the service.dvla_org_id is not 001 (hm-government)
2019-02-07 14:28:09 +00:00
Pea Tyczynska
ab5fd972b0 Migrate postage into templates_history table 2019-02-05 15:00:53 +00:00
Chris Hill-Scott
cf2d88c87e Squeeze in some letter logos too 2019-02-01 15:11:51 +00:00
Chris Hill-Scott
a04f41d4d8 Give folders to all existing services
Step 2 of 2 of shipping folders.
2019-02-01 15:04:27 +00:00
Pea Tyczynska
c32fdfa008 Set postage for all existing templates to service default 2019-02-01 12:57:38 +00:00
Rebecca Law
e030c2be88 Removing platform_default as a concept. No service actually wants to send letters with the default hm-government logo so we are going to remove it as a constraint.
However, until we can create a letter without a logo, we will still default to hm-government, because the dvla_organisation is set on the service.
This does simplify the code.
Also removed the inserts to letter_branding in the data migration file, because we can deploy this before the rest of the work is finished. But we will need to do it later.
2019-01-25 15:03:01 +00:00
Rebecca Law
f11aa55e0b Adding new data models for letter branding. 2019-01-22 17:27:00 +00:00
Rebecca Law
52a1b534ee Add a new data model LETTER_BRANDING to store the letters. Add a new data model SERVICE_LETTER_BRANDING to map the service to the letter brand.
This will replace services.dvla_organisation_id and dvla_organisation.
2019-01-21 13:59:27 +00:00