<?php

namespace KupShop\AdminBundle\Resources\upgrade;

class AdminFiltersUpgrade extends \UpgradeNew
{
    protected $priority = 100;

    public function check_sortColumnExists()
    {
        return $this->checkColumnExists('admin_filters', 'sort');
    }

    /** Add sort column to admin_filters */
    public function upgrade_sortColumnExists()
    {
        $name = translate('default', 'filters', false, true);

        sqlQuery('ALTER TABLE admin_filters ADD COLUMN sort TEXT DEFAULT NULL AFTER list');
        sqlQuery('UPDATE admin_filters SET name = "'.$name.'" WHERE default_filter = "Y" AND name = ""');

        $this->upgradeOK();
    }
}
