"""Add manually_deleted_at column to wordpress_site table.

Mirrors imav/migrations/015_manually_deleted_at_field_added.py so that
fresh installs get the complete schema from core alone. The
database.get_columns() guard makes this idempotent on existing installs
where imav/015 already added the column.

Rollback is a no-op because imav/015 owns the actual schema undo.
"""

from peewee import TimestampField


def migrate(migrator, database, fake=False, **kwargs):
    if fake:
        return
    columns = [col.name for col in database.get_columns("wordpress_site")]
    if "manually_deleted_at" not in columns:
        WordpressSite = migrator.orm["wordpress_site"]
        migrator.add_columns(
            WordpressSite, manually_deleted_at=TimestampField(null=True)
        )


def rollback(migrator, database, fake=False, **kwargs):
    pass
