"""Peewee migrations -- 174_MAIN.py.

Rename Order.customer -> Order.customer_name and
Order.construction_site -> Order.construction_site_name
to follow the naming convention used by PumpOrder and Delivery.
"""

from contextlib import suppress

import peewee as pw
from peewee_migrate import Migrator


with suppress(ImportError):
    import playhouse.postgres_ext as pw_pext


def migrate(migrator: Migrator, database: pw.Database, *, fake=False):
    """Write your migrations here."""

    migrator.rename_field('order', 'customer', 'customer_name')
    migrator.rename_field('order', 'construction_site', 'construction_site_name')


def rollback(migrator: Migrator, database: pw.Database, *, fake=False):
    """Write your rollback migrations here."""

    migrator.rename_field('order', 'customer_name', 'customer')
    migrator.rename_field('order', 'construction_site_name', 'construction_site')
