"""Create wordpress_site table in defence360agent migrations.

The table was originally created in imav/migrations/014_add_imunify_security.py,
but the wordpress code has been moved to defence360agent. This migration ensures
the table exists (and is registered in the ORM) before defence360agent migrations
that reference it.

Both this migration and imav/migrations/014_add_imunify_security.py migration, 
uses migrator.create_model(WordpressSite) which is equivalent to 
`CREATE TABLE IF NOT EXISTS`, so it's a no-op on existing installs
where imav/014 already created the table.
"""

from peewee import IntegerField, CharField, Model


class WordpressSite(Model):
    class Meta:
        db_table = "wordpress_site"

    docroot = CharField(primary_key=True, null=False)
    domain = CharField(null=False)
    uid = IntegerField(null=False)


def migrate(migrator, database, fake=False, **kwargs):
    migrator.create_model(WordpressSite)


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