mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
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.
This commit is contained in:
35
migrations/versions/0283_platform_admin_not_live.py
Normal file
35
migrations/versions/0283_platform_admin_not_live.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0283_platform_admin_not_live
|
||||
Revises: 0282_add_count_as_live
|
||||
Create Date: 2016-10-25 17:37:27.660723
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0283_platform_admin_not_live'
|
||||
down_revision = '0282_add_count_as_live'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
STATEMENT = """
|
||||
UPDATE
|
||||
services
|
||||
SET
|
||||
count_as_live = {count_as_live}
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
services.created_by_id = users.id and
|
||||
users.platform_admin is true
|
||||
;
|
||||
"""
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute(STATEMENT.format(count_as_live='false'))
|
||||
|
||||
def downgrade():
|
||||
op.execute(STATEMENT.format(count_as_live='true'))
|
||||
Reference in New Issue
Block a user