def upgrade(): bind = op.get_bind() session = db.Session(bind=bind) for obj in session.query(Database).all(): obj.allow_run_sync = True session.commit() session.close()
def upgrade(): bind = op.get_bind() session = db.Session(bind=bind) objects = session.query(models.Slice).all() objects += session.query(models.Dashboard).all() for obj in objects: if obj.created_by and obj.created_by not in obj.owners: obj.owners.append(obj.created_by) session.commit() session.close()
def upgrade(): bind = op.get_bind() op.add_column('slices', sa.Column('perm', sa.String(length=2000), nullable=True)) session = db.Session(bind=bind) for slc in session.query(models.Slice).all(): if slc.datasource: slc.perm = slc.datasource.perm session.merge(slc) session.commit() db.session.close()
def downgrade(): bind = op.get_bind() session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.datasource_type == 'druid': slc.druid_datasource_id = slc.datasource_id if slc.datasource_type == 'table': slc.table_id = slc.datasource_id session.merge(slc) session.commit() session.close() op.drop_column('slices', 'datasource_id')
def upgrade(): bind = op.get_bind() op.add_column('slices', sa.Column('datasource_id', sa.Integer())) session = db.Session(bind=bind) for slc in session.query(Slice).all(): if slc.druid_datasource_id: slc.datasource_id = slc.druid_datasource_id if slc.table_id: slc.datasource_id = slc.table_id session.merge(slc) session.commit() session.close()
def upgrade(): op.add_column('metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) op.add_column('sql_metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) bind = op.get_bind() session = db.Session(bind=bind) session.query(models.DruidMetric).update({'is_restricted': False}) session.query(models.SqlMetric).update({'is_restricted': False}) session.commit() session.close()
def upgrade(): op.add_column('metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) op.add_column('sql_metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) bind = op.get_bind() session = db.Session(bind=bind) # don't use models.DruidMetric # because it assumes the context is consistent with the application for obj in session.query(DruidMetric).all(): obj.is_restricted = False for obj in session.query(SqlMetric).all(): obj.is_restricted = False session.commit() session.close()
def upgrade(): with op.batch_alter_table('metrics', schema=None) as batch_op: batch_op.add_column( sa.Column('is_restricted', sa.Boolean(), nullable=True)) with op.batch_alter_table('sql_metrics', schema=None) as batch_op: batch_op.add_column( sa.Column('is_restricted', sa.Boolean(), nullable=True)) bind = op.get_bind() session = db.Session(bind=bind) session.query(models.DruidMetric).update({'is_restricted': False}) session.query(models.SqlMetric).update({'is_restricted': False}) session.commit() session.close()
def upgrade(): op.add_column('metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) op.add_column('sql_metrics', sa.Column('is_restricted', sa.Boolean(), nullable=True)) bind = op.get_bind() session = db.Session(bind=bind) for obj in session.query(models.DruidMetric).all(): obj.is_restricted = False for obj in session.query(models.SqlMetric).all(): obj.is_restricted = False session.commit() session.close()