from __future__ import unicode_literals

import logging

from sqlalchemy import Table, MetaData
from corehq.db import connection_manager
from django.db import migrations


def drop_tables(apps, schema_editor):
    # show SQL commands
    logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

    metadata = MetaData(bind=connection_manager.get_engine())

    for table_name in [
        'fluff_OPMHierarchyFluff',
        'fluff_OpmCaseFluff',
        'fluff_OpmFormFluff',
        'fluff_OpmHealthStatusAllInfoFluff',
        'fluff_VhndAvailabilityFluff',
    ]:
        Table(table_name, metadata).drop(checkfirst=True)


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.RunPython(drop_tables),
    ]

from __future__ import unicode_literals

import logging

from sqlalchemy import Table, MetaData
from corehq.db import connection_manager
from corehq.util.decorators import change_log_level
from django.db import migrations


@change_log_level('sqlalchemy.engine', logging.INFO)  # show SQL commands
def drop_tables(apps, schema_editor):
    metadata = MetaData(bind=connection_manager.get_engine())

    for table_name in [
        'fluff_OPMHierarchyFluff',
        'fluff_OpmCaseFluff',
        'fluff_OpmFormFluff',
        'fluff_OpmHealthStatusAllInfoFluff',
        'fluff_VhndAvailabilityFluff',
    ]:
        Table(table_name, metadata).drop(checkfirst=True)


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.RunPython(drop_tables),
    ]

Make sure log level gets reset afterwards
Make sure log level gets reset afterwards

  from __future__ import unicode_literals
  
  import logging
  
  from sqlalchemy import Table, MetaData
  from corehq.db import connection_manager
+ from corehq.util.decorators import change_log_level
  from django.db import migrations
  
  
+ @change_log_level('sqlalchemy.engine', logging.INFO)  # show SQL commands
  def drop_tables(apps, schema_editor):
-     # show SQL commands
-     logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
- 
      metadata = MetaData(bind=connection_manager.get_engine())
  
      for table_name in [
          'fluff_OPMHierarchyFluff',
          'fluff_OpmCaseFluff',
          'fluff_OpmFormFluff',
          'fluff_OpmHealthStatusAllInfoFluff',
          'fluff_VhndAvailabilityFluff',
      ]:
          Table(table_name, metadata).drop(checkfirst=True)
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
      ]
  
      operations = [
          migrations.RunPython(drop_tables),
      ]
  
Make sure log level gets reset afterwards
## Code Before:
from __future__ import unicode_literals

import logging

from sqlalchemy import Table, MetaData
from corehq.db import connection_manager
from django.db import migrations


def drop_tables(apps, schema_editor):
    # show SQL commands
    logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

    metadata = MetaData(bind=connection_manager.get_engine())

    for table_name in [
        'fluff_OPMHierarchyFluff',
        'fluff_OpmCaseFluff',
        'fluff_OpmFormFluff',
        'fluff_OpmHealthStatusAllInfoFluff',
        'fluff_VhndAvailabilityFluff',
    ]:
        Table(table_name, metadata).drop(checkfirst=True)


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.RunPython(drop_tables),
    ]

## Instruction:
Make sure log level gets reset afterwards
## Code After:
from __future__ import unicode_literals

import logging

from sqlalchemy import Table, MetaData
from corehq.db import connection_manager
from corehq.util.decorators import change_log_level
from django.db import migrations


@change_log_level('sqlalchemy.engine', logging.INFO)  # show SQL commands
def drop_tables(apps, schema_editor):
    metadata = MetaData(bind=connection_manager.get_engine())

    for table_name in [
        'fluff_OPMHierarchyFluff',
        'fluff_OpmCaseFluff',
        'fluff_OpmFormFluff',
        'fluff_OpmHealthStatusAllInfoFluff',
        'fluff_VhndAvailabilityFluff',
    ]:
        Table(table_name, metadata).drop(checkfirst=True)


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.RunPython(drop_tables),
    ]
