Commit Graph

434 Commits

Author SHA1 Message Date
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
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
Rebecca Law
0bc42d1873 Forgot script 2018-01-05 15:58:13 +00:00
Rebecca Law
9e9b8ab1a3 There was a misunderstanding about how we wanted the feature to work.
There is no need for the extra column.
If a template does not have a default address set - they address will be blank.
Otherwise use the address of the service_letter_contact.

There will be another PR to do a db migration.
Template.service_letter_contact = blank if no service_letter_contacts for service ELSE use set Template.serivce_letter_contact_id = service default service_letter_contact
2018-01-05 15:32:43 +00:00
Rebecca Law
6a3831eace Added a boolean column to templates called is_letter_contact_blank.
If is_letter_contact_blank then the user has set the letter contact block to be blank on purpose
ELSE IF is_letter_contact_blank is false THEN use the template default
IF template default is blank THEN the service_letter_contact is blank use the service default
2018-01-04 11:33:10 +00:00
venusbb
689ece75a0 db version change 2017-12-13 10:03:40 +00:00
Leo Hemsted
ea71af695d Merge branch 'master' into remove-fragments-from-db 2017-12-12 16:32:07 +00:00
Leo Hemsted
08b21bc0f4 remove fragments from db 2017-12-07 10:23:41 +00:00
Rebecca Law
da656af6e0 Fix merge conflict with db script 2017-12-06 17:26:32 +00:00
Rebecca Law
ad060435ca Merge branch 'master' into refactor-letter-rates 2017-12-06 17:25:39 +00:00
Rebecca Law
14be85160c Insert initial letter rates.
Create letter rates dao.
Query to fetch letter rates.
2017-12-06 16:40:38 +00:00
Chris Hill-Scott
64f13a0064 Add a new organisation for letter branding 2017-12-05 13:56:13 +00:00
Rebecca Law
07a71ef71c Fix db migration script 2017-12-05 13:54:10 +00:00
Rebecca Law
91e6cb9215 Merge branch 'master' into refactor-letter-rates 2017-12-05 12:03:13 +00:00
Rebecca Law
956907c170 Revert the last commit. It was intended for another branch. 2017-12-05 10:54:55 +00:00
Rebecca Law
00d2e543dc Refactor letter_rates table to include everything needed to calculate billing for letter notificaitons.
It is ok to drop the existing tables as they are not used anywhere as of yet.
2017-12-05 10:32:19 +00:00
Rebecca Law
06a6d37595 Merge branch 'master' into add-crown-column-to-services 2017-12-05 10:28:26 +00:00
Rebecca Law
b4a1d635f7 Rebuild the letter_rates table to include everything it needs.
The current letter_rates table is not used so it is ok to drop and re-create it
2017-12-05 10:27:29 +00:00
Rebecca Law
7fa4e7ffc7 Set crown if organisation_type is updated on service.
Add some tests.
Update the initial values of crown.
2017-12-04 16:07:26 +00:00
Katie Smith
f73319f5ef Add and populate crown column to services and services_history
- Added the boolean 'crown' column to services and services_history tables
- We populate this column in the same migration script by checking the
'organisation_type' of a service
2017-12-04 13:31:08 +00:00
Ken Tsang
907a9d62a1 Add letters_as_pdf service permission 2017-12-01 17:25:20 +00:00
Rebecca Law
12dd58d281 Script to drop the tables. 2017-11-30 16:51:26 +00:00
venusbb
5761d22822 Migration to create new database table service_callback_api 2017-11-28 15:25:15 +00:00
Rebecca Law
5450af661e Merge branch 'master' into add-reply-to-notifications 2017-11-27 10:40:02 +00:00
Leo Hemsted
d30a8b83c1 update readme and ensure makefile up to date 2017-11-23 17:04:58 +00:00
Rebecca Law
df2d3a95ae [WIP] 2017-11-23 14:55:49 +00:00
Rebecca Law
80db78e7a5 Fix merge conflict 2017-11-23 13:46:14 +00:00
Rebecca Law
a19cb66590 Merge branch 'master' into add-reply-to-notifications 2017-11-23 13:45:27 +00:00
Rebecca Law
1378c45ba1 Add a column to Notifications to store the reply_to_text.
This is text value of the sender_id, depending on the channel this will be a SMS sender, email reply to address or a letter contact block.
This is the first PR in a series to refactor how we send the "reply_to" the provider, eventually we can eliminate the notification_to_sms_sender and notification_to_email_to tables.
2017-11-22 14:46:14 +00:00
Alexey Bezhan
0be39cc9f9 Add a migration to add template service_letter_contact_id columns 2017-11-22 14:26:04 +00:00
Rebecca Law
c80bdbaffe Remove email_reply_to and letter_contact_block from Services 2017-11-21 11:06:07 +00:00
Alexey Bezhan
0a50993fc2 Validate notifcations.template_history foreign key constraints
Removes "NOT VALID" mark from the notifications -> template_history
foreign key constraint by validating existing records.

From postgres docs:

> This form validates a foreign key or check constraint that was
> previously created as NOT VALID, by scanning the table to ensure there
> are no rows for which the constraint is not satisfied. Nothing happens
> if the constraint is already marked valid.

> Validation can be a long process on larger tables. The value of
> separating validation from initial creation is that you can defer
> validation to less busy times, or can be used to give additional time
> to correct pre-existing errors while preventing new errors. Note also
> that validation on its own does not prevent normal write commands
> against the table while it runs.

> Validation acquires only a SHARE UPDATE EXCLUSIVE lock on the table
> being altered. If the constraint is a foreign key then a ROW SHARE
> lock is also required on the table referenced by the constraint.
2017-11-20 15:23:27 +00:00
Rebecca Law
93f19956b8 Remove notification_statistics and Service.sms_sender 2017-11-20 13:13:13 +00:00
Chris Hill-Scott
e8a94422e5 Make SMS prefix setting non-nullable
We have now:
- defaulted new services to start with this column set to `true`
- migrated all preexisting services[1] to have either `true` or `false` set
  for this column

There is no way for a service to switch back from `true`/`false` to
`null`.

This means that we can safely enforce a non-nullable constraint on this
column now.

1. There is a little gotcha: the GOV.UK Notify service still relies on
   the `sms_sender` column. It doesn’t have a row in the
   `service_sms_senders` table. This means the previous migration
   never changed this service’s value for `prefix_sms` from `null`. So
   this commit also changes its value to `False`, so that the rest of
   the migration, of the whole column, is possible.
2017-11-16 14:29:32 +00:00