Merge pull request #2286 from alphagov/folders-for-all-services

Give folders to all existing services
This commit is contained in:
Chris Hill-Scott
2019-02-01 15:19:35 +00:00
committed by GitHub
2 changed files with 77 additions and 0 deletions

View 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

View 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))