<?php
$db->exec("ALTER TABLE partners ADD lowername VARCHAR DEFAULT ''");
$db->exec("CREATE INDEX partners_partner_id ON partners (partner_id)");
$db->exec("CREATE INDEX partners_card ON partners (card)");
$db->exec("CREATE INDEX partners_email ON partners (phone)");
$db->exec("CREATE INDEX inn ON partners (inn)");
$db->exec("CREATE INDEX lowername ON partners (lowername)");
$partners=$db->query("SELECT partner_id, name FROM partners");
if($partners) {
	while ($partner=$partners->fetchArray()) {
		$db->exec("UPDATE partners SET lowername='".mb_strtolower($partner['name'])."' WHERE partner_id='".$partner['partner_id']."'");
	}
}