Commit Graph

385 Commits

Author SHA1 Message Date
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
venusbb
7ac0346961 change migration version 2017-11-16 13:44:55 +00:00
Venus Bailey
bb0c8090c5 Merge pull request #1389 from alphagov/vb-sms-allowance-data-migration
migrate data from service table to annual billing
2017-11-16 13:16:15 +00:00
Rebecca Law
9fa59c9407 Fix merge conflict 2017-11-15 12:42:49 +00:00
Rebecca Law
fd217e67f5 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-15 12:33:38 +00:00
venusbb
e903257156 version change because of other commits 2017-11-15 11:25:27 +00:00
Alexey Bezhan
d2a220a418 Fix migration numbers after #1383 2017-11-15 11:03:55 +00:00
Rebecca Law
45bf7e1938 Fix db migration merge conflict
Update create_service_with_inbound_number
2017-11-15 11:00:56 +00:00
venusbb
fcfea6844d Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-sms-allowance-data-migration 2017-11-15 10:54:22 +00:00
Alexey Bezhan
bc54d34a22 Merge pull request #1384 from alphagov/notifications-template-history
Fix notifications template history relationship
2017-11-15 10:51:56 +00:00
Rebecca Law
e3f9dab884 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-14 16:27:10 +00:00
venusbb
7c0c2a9a0f migrate data from service table to annual billing 2017-11-14 09:43:28 +00:00
Alexey Bezhan
9d4b8961cb Add a migration to replace notifications_template foreign key
Removes notifications.template_id foreign key and replaces it with
a composite foreign key constraint to TemplateHistory using the
existing notification columns for template ID and template version.

Foreign key constraint is created as NOT VALID to avoid locking the
notifications table while postgres verifies that existing records
don't break the constraint. From postgres docs:

> If the constraint is marked NOT VALID, the potentially-lengthy initial
> check to verify that all rows in the table satisfy the constraint is
> skipped. The constraint will still be enforced against subsequent
> inserts or updates (that is, they'll fail unless there is a matching
> row in the referenced table, in the case of foreign keys; and they'll
> fail unless the new row matches the specified check constraints). But
> the database will not assume that the constraint holds for all rows
> in the table, until it is validated by using the VALIDATE CONSTRAINT
> option.

VALIDATE CONSTRAINT will be issued as a separate migration in a
follow-up PR.
2017-11-10 15:13:55 +00:00
Leo Hemsted
15bf888624 make user mobile num nullable if user has email_auth enabled 2017-11-09 19:07:44 +00:00
Richard Chapman
b78d989d4e Updates after review
- Modified the services_dao to return an int instead of a datetime to
make usage easier and removed the BST function on year as it is not
relevant for year
- Improved tests do there is less logic by ordering the result so there
is less reliance on the template id
- Renamed variable in stats_template_usage_by_month_dao.py to make it
consistent with the method
2017-11-09 14:13:42 +00:00
Rebecca Law
3713cc2353 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-09 11:53:29 +00:00
Richard Chapman
98b762869d Renamed database migration file after merge
Updated the database migration file name after a rebase as there were
two 0134 files and this would break the upgrade / downgrade process.
2017-11-09 10:41:43 +00:00
Richard Chapman
ab43803453 Removed unwanted migration commands
There were some unwanted db migration commands which crept into the
migration file. removed these as they are being handled in other PRs.
2017-11-09 10:34:49 +00:00
Richard Chapman
26617a921e Added database migration file
Currently the 'See templates used by month' report is timing out for
some services due to the query time of the data from notification_history
This is a stats table which will hold the data and will be updated by a
scheduled celery task once a day. This data will be combined with the
'live' data from notifications tables (which will be considerably less)
to form the data of the new report.
2017-11-09 10:34:49 +00:00
Leo Hemsted
57b7a392b2 add email 2fa template 2017-11-07 16:47:20 +00:00
Rebecca Law
0054361044 Refactor the sms sender code to remove any unused methods.
Refactor tests/db/create_service() to behave more like the real world.
Created new create_service_with_inbound_number and create_service_with_defined_sms_sender() test/db methods.
2017-11-07 14:26:18 +00:00
Chris Hill-Scott
97db65bc9e Migrate prefix SMS setting to be true or false
We want services to have control over this setting, rather than deriving
it from the value of their sender. This commit does that derivation one
last time, and stores it in the column, where it can be changed as and
when needed.
2017-11-07 10:47:13 +00:00
Chris Hill-Scott
cccffdd2ac Add a column for a service to set SMS prefixing
In future changes, services will be able to control whether their text
messages will be prefixed with the name of their service.

This commit:
- adds a column to store the value of that setting
- makes the service model take notice of it, if it were to have a value
  set

It doesn’t:
- provide a way of setting the value of this column

Currently the column can have three values:
- `None` – ignore it (this is what all current services will start as)
  and continue to determine whether to prefix messages by looking at the
  sender
- `True` – always the service name to the start of text messages
- `False` – never add the service name to the start of text messages

In the future we’ll migrate all services to be either `True` or `False`,
the `None` will go away and all services will have direct control over
the setting.
2017-11-03 12:53:06 +00:00
Leo Hemsted
0ab89116ee use server_default in alembic to ensure zero-downtimeness
we can back-fill data, however, between alembic running and the api
updating to the new code, it'll still try and create new users without
adding the auth_type, because that won't be referenced in the model yet.

Instead of using a python-level default, a postgres-level
server_default will make postgres set every row to sms_auth if it's not
defined in the application.
2017-10-30 11:59:35 +00:00
Leo Hemsted
c39ec90727 add auth type table, currently contains sms_auth and email_auth 2017-10-30 11:11:37 +00:00
Ken Tsang
8a4c8802ef Add notification email reply_to script 2017-10-27 15:11:35 +01:00
Leo Hemsted
46f5896b3b add new email_auth service permission 2017-10-27 14:28:20 +01:00
Rebecca Law
b048b2c3bf DB update script for new table 2017-10-26 16:40:38 +01:00
Rebecca Law
d975f30888 Fix merge conflict 2017-10-19 14:39:53 +01:00
Rebecca Law
954a80649e Merge branch 'master' into add-update-multiple-sms-sender 2017-10-19 14:34:58 +01:00
venusbb
7e78e19500 Unique constrain and db.relationship 2017-10-19 12:00:01 +01:00
venusbb
b2fa7cdd83 create new table annual_billing 2017-10-18 15:35:51 +01:00
Rebecca Law
4ca6fbc724 Added dao methods needed to add or update multiple sms senders for a service.
Remove the unique constraint for service on the ServiceSmsSender model.
2017-10-18 13:13:23 +01:00
Rebecca Law
1a463cba1f Merge branch 'master' into add-update-multiple-sms-sender 2017-10-18 11:18:44 +01:00
Chris Hill-Scott
2a5e6c2d0c Store organisation type against each service
> So that we can default services to their appropriate text allowance,
> we need to find out what sector they're in. So let's start collecting
> that from teams as they create new services.

In order to work out what a team’s allowance should be, we need to know
what part of government they’re from. We’re going to do this logic in
the admin app and then `POST` the allowance to the API.

So all we need to do with the information that the users give us is
store it against the service, so we have a record. Doesn’t need any
logic doing as a result of it, doesn’t need foreign keying to the
organisations table, etc.
2017-10-18 10:49:31 +01:00
Rebecca Law
edba490c72 Remove unique constraint for ServiceSmsSenders.
This will allow a service to have multiple sms senders.
2017-10-17 16:53:13 +01:00
Venus Bailey
9b60d69931 Revert "Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table"" 2017-10-16 16:24:34 +01:00
Venus Bailey
616a6f8ef8 Revert "[#151837054] Add new column free_sms_fragment_limit in the Services table" 2017-10-16 12:43:05 +01:00
venusbb
f95282a84d Add column, free_sms_fragment_limit, to services & services_history
- Created new column in both tables
- Modified model and Service schema
- Modifed existing test
2017-10-12 12:16:13 +01:00
Richard Chapman
d8e1a34610 Added a unique constraint to the notification_id column of the notification_to_email_reply_to table so that each notification can only have one mapping to service_email_reply_to and hence one email address. 2017-10-03 11:03:31 +01:00
Richard Chapman
fdc4d4c24f Reanmed the link table to be a bteer description of what the table is for as it was previously confusing. Updated the migration script to reflect those changes 2017-09-28 11:11:41 +01:00
Richard Chapman
6356a5320a Updated model with a new table notification_to_email_sender and created db migration script 2017-09-27 10:36:25 +01:00
Ken Tsang
366d07dbbe Add ServiceLetterContact data model and script 2017-09-21 16:08:49 +01:00
Chris Hill-Scott
bde6a9e131 Make organisation logo nullable
Now we have the org banner branding, not all organisations need a logo.
So it shouldn’t be an error to not provide one.
2017-09-20 11:06:16 +01:00
chrisw
f49eca5324 Add a non-GOV.UK banner option for email branding
Added an extra name, 'org_banner', for branding types into branding_type table
Added org banner into user model in database
Added checks for new branding type to ensure that the correct data is passed into the dict
Tested new checks in html email options
2017-09-19 14:40:22 +01:00
Imdad Ahad
d997eb3af9 Create ServiceEmailReplyTo table 2017-09-07 15:41:23 +01:00
Imdad Ahad
b85ff4e6a6 Update the alembic generator template to be PEP friendly 2017-09-07 15:41:04 +01:00
Rebecca Law
3b115cc79f Remove the or current_app['FROM_NUMBER'] since sms_sender is a required field. 2017-09-06 15:33:09 +01:00
Rebecca Law
86929fd6b6 Create a table for service_sms_senders.
Migration from inbound_number to service_sms_senders.
May need to pull out the migration into another PR.
2017-09-05 17:53:47 +01:00
Chris Hill-Scott
caea65165c Allow Notify service to send international sms
Right now Notify restricts you to registering with a UK mobile number.
This is because when we built the user registration stuff we couldn’t
send to international mobiles.

However we can send to international mobile numbers, and it’s totally
reasonable to expect employees of the UK government to be working
abroad, and have a foreign mobile phone – we’ve heard from one such
user.

In order for users of Notify to register with an international phone
number, the Notify service needs to have the `international_sms`
permission set. Which this service does, as a data migration.
2017-08-29 15:18:49 +01:00