# Path: borme/parser/postgres.py
# def psql_update_documents():
#     """
#     Update postgresql full text search attributes.
#     This function must be run everytime new records are added to the database
#     """
#     affected_rows = 0
# 
#     with connection.cursor() as cursor:
#         cursor.execute("UPDATE borme_company "
#                        "SET document = to_tsvector(name) "
#                        "WHERE document IS NULL")
#         affected_rows += cursor.rowcount
#         logger.info("Updated {} borme_company records".format(cursor.rowcount))
# 
#     with connection.cursor() as cursor:
#         cursor.execute("UPDATE borme_person "
#                        "SET document = to_tsvector(name) "
#                        "WHERE document IS NULL")
#         affected_rows += cursor.rowcount
#         logger.info("Updated {} borme_company records".format(cursor.rowcount))
# 
#     return affected_rows


from django.core.management.base import BaseCommand
from borme.parser.postgres import psql_update_documents



class Command(BaseCommand):
    help = 'Update FTS PostgreSQL document fields'

    def handle(self, *args, **options):

# Path: borme/parser/postgres.py
# def psql_update_documents():
#     """
#     Update postgresql full text search attributes.
#     This function must be run everytime new records are added to the database
#     """
#     affected_rows = 0
# 
#     with connection.cursor() as cursor:
#         cursor.execute("UPDATE borme_company "
#                        "SET document = to_tsvector(name) "
#                        "WHERE document IS NULL")
#         affected_rows += cursor.rowcount
#         logger.info("Updated {} borme_company records".format(cursor.rowcount))
# 
#     with connection.cursor() as cursor:
#         cursor.execute("UPDATE borme_person "
#                        "SET document = to_tsvector(name) "
#                        "WHERE document IS NULL")
#         affected_rows += cursor.rowcount
#         logger.info("Updated {} borme_company records".format(cursor.rowcount))
# 
#     return affected_rows


# Path: borme/management/commands/updatefts.py
from django.core.management.base import BaseCommand
from borme.parser.postgres import psql_update_documents




class Command(BaseCommand):
    help = 'Update FTS PostgreSQL document fields'

    def handle(self, *args, **options):

        affected_rows = psql_update_documents()