"""Add manually_deleted_at column to wordpress_site table.

The database.get_columns() guard makes this idempotent on installs where
imav/015 (now retained as a no-op) had already added the column.
"""

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
