mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 07:46:06 -04:00
Merge pull request #2286 from alphagov/folders-for-all-services
Give folders to all existing services
This commit is contained in:
38
migrations/versions/0254_folders_for_all.py
Normal file
38
migrations/versions/0254_folders_for_all.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: 0254_folders_for_all
|
||||||
|
Revises: 0253_set_template_postage
|
||||||
|
Create Date: 2019-01-08 13:30:48.694881+00
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
revision = '0254_folders_for_all'
|
||||||
|
down_revision = '0253_set_template_postage'
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.execute("""
|
||||||
|
INSERT INTO
|
||||||
|
service_permissions (service_id, permission, created_at)
|
||||||
|
SELECT
|
||||||
|
id, '{permission}', now()
|
||||||
|
FROM
|
||||||
|
services
|
||||||
|
WHERE
|
||||||
|
NOT EXISTS (
|
||||||
|
SELECT
|
||||||
|
FROM
|
||||||
|
service_permissions
|
||||||
|
WHERE
|
||||||
|
service_id = services.id and
|
||||||
|
permission = '{permission}'
|
||||||
|
)
|
||||||
|
""".format(
|
||||||
|
permission='edit_folders'
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
pass
|
||||||
39
migrations/versions/0255_another_letter_org.py
Normal file
39
migrations/versions/0255_another_letter_org.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0255_another_letter_org
|
||||||
|
Revises: 0254_folders_for_all
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0255_another_letter_org'
|
||||||
|
down_revision = '0254_folders_for_all'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
NEW_ORGANISATIONS = [
|
||||||
|
('010', 'Disclosure and Barring Service', 'dbs'),
|
||||||
|
('527', 'Natural Resources Wales', 'natural-resources-wales'),
|
||||||
|
('528', 'North Yorkshire Council', 'north-yorkshire'),
|
||||||
|
('529', 'Redbridge Council', 'redbridge'),
|
||||||
|
('530', 'Wigan Council', 'wigan'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||||
|
op.execute("""
|
||||||
|
INSERT
|
||||||
|
INTO dvla_organisation
|
||||||
|
VALUES ('{}', '{}', '{}')
|
||||||
|
""".format(numeric_id, name, filename))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||||
|
op.execute("""
|
||||||
|
DELETE
|
||||||
|
FROM dvla_organisation
|
||||||
|
WHERE id = '{}'
|
||||||
|
""".format(numeric_id))
|
||||||
Reference in New Issue
Block a user