Skip to content

Instantly share code, notes, and snippets.

@full-of-foo
Created December 30, 2014 09:57
Show Gist options
  • Save full-of-foo/2a1b619776a2484519db to your computer and use it in GitHub Desktop.
Save full-of-foo/2a1b619776a2484519db to your computer and use it in GitHub Desktop.
"""[GoodData][2115] Add _dashboard JSON column business model
Revision ID: 94fa184253c
Revises: b28edc5f867
Create Date: 2014-12-29 20:09:59.721904
"""
# revision identifiers, used by Alembic.
revision = '94fa184253c'
down_revision = 'b28edc5f867'
# For pure schema migrations, set to False
data_migration = False
if data_migration:
import transaction
from webapp import model
from ftlib.configure import configure_audit_trail
import logging
from alembic import op, context
import sqlalchemy as sa
from webapp.model import fttypes
import valideer as V
from webapp.model.business import DASHBOARD_COLUMN_SCHEMA, DEFAULT_DASHBOARD_SETTINGS
logger = logging.getLogger('alembic')
def upgrade():
if data_migration:
configure_audit_trail(context.config.get_section('DEFAULT'))
# Migration
op.add_column('businesses', fttypes.DashboardColumn(
"_dashboard", V.parse(DASHBOARD_COLUMN_SCHEMA), default=DEFAULT_DASHBOARD_SETTINGS)
)
if data_migration:
logger.info("Committing transaction...")
transaction.commit()
logger.info("Done")
def downgrade():
op.drop_column('businesses', '_dashboard')
logger.info("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment