znt/module/upgrade/test/model/addadmininvitefield.php

33 lines
974 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
title=测试 upgradeModel->addAdminInviteField();
cid=19495
- 修改后im_chart表中存在adminInvite字段 @adminInvite
**/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$upgrade = new upgradeModelTest();
$checkExistSql = "show columns from `%s` like '%s'";
$dropSql = "Alter table `%s` drop column `%s`";
global $config, $tester;
$table = $config->db->prefix . 'im_chat';
$column = 'adminInvite';
$result = $tester->dbh->query(sprintf($checkExistSql, $table, $column))->fetch();
if($result) $deleteAction = $tester->dbh->exec(sprintf($dropSql, $table, $column)); //检测到adminInvite字段存在删除该字段
$upgrade->addAdminInviteField();
$result2 = $tester->dbh->query(sprintf($checkExistSql, $table, $column))->fetch();
r($result2) && p('Field') && e('adminInvite'); //修改后im_chart表中存在adminInvite字段