mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-02 07:10:14 -04:00
add organisation and branding models
a service now has branding and organisation_id columns, and two new
tables have been aded to reflect these:
* branding is a static types table referring to how a service wants
their emails to be branded:
* 'govuk' for GOV UK branding (default)
* 'org' for organisational branding only
* 'both' for co-branded output with both
* organisation is a table defining an organisation's branding. this
contains three entries, all of which are nullable
* colour - a hex code for a coloured bar on the logo's left
* logo - relative path for that org's logo image
* name - the name to display on the right of the logo
This commit is contained in:
57
migrations/versions/0046_organisations_and_branding.py
Normal file
57
migrations/versions/0046_organisations_and_branding.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0046_organisations_and_branding
|
||||
Revises: 0045_billable_units
|
||||
Create Date: 2016-08-04 12:00:43.682610
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0046_organisations_and_branding'
|
||||
down_revision = '0045_billable_units'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.create_table('branding_type',
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint('name')
|
||||
)
|
||||
op.create_table('organisation',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('colour', sa.String(length=7), nullable=True),
|
||||
sa.Column('logo', sa.String(length=255), nullable=True),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.add_column('services', sa.Column('branding', sa.String(length=255)))
|
||||
op.add_column('services', sa.Column('organisation_id', postgresql.UUID(as_uuid=True)))
|
||||
op.add_column('services_history', sa.Column('branding', sa.String(length=255)))
|
||||
op.add_column('services_history', sa.Column('organisation_id', postgresql.UUID(as_uuid=True)))
|
||||
|
||||
op.execute("INSERT INTO branding_type VALUES ('govuk'), ('org'), ('both')")
|
||||
op.execute("UPDATE services SET branding='govuk'")
|
||||
op.execute("UPDATE services_history SET branding='govuk'")
|
||||
|
||||
op.alter_column('services', 'branding', nullable=False)
|
||||
op.alter_column('services_history', 'branding', nullable=False)
|
||||
|
||||
op.create_index(op.f('ix_services_branding'), 'services', ['branding'], unique=False)
|
||||
op.create_index(op.f('ix_services_organisation_id'), 'services', ['organisation_id'], unique=False)
|
||||
op.create_index(op.f('ix_services_history_branding'), 'services_history', ['branding'], unique=False)
|
||||
op.create_index(op.f('ix_services_history_organisation_id'), 'services_history', ['organisation_id'], unique=False)
|
||||
|
||||
op.create_foreign_key(None, 'services', 'branding_type', ['branding'], ['name'])
|
||||
op.create_foreign_key(None, 'services', 'organisation', ['organisation_id'], ['id'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('services_history', 'organisation_id')
|
||||
op.drop_column('services_history', 'branding')
|
||||
op.drop_column('services', 'organisation_id')
|
||||
op.drop_column('services', 'branding')
|
||||
op.drop_table('organisation')
|
||||
op.drop_table('branding_type')
|
||||
Reference in New Issue
Block a user