"""Add version column to wordpress_site table.

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

from peewee import CharField


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


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