hzr
2024-08-05 0a2757042cb3bc30831e7dde93cfb3aee2280d47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
include_once '/Common/CommFunc.php';
include_once '/Common/Logging.php';
include_once "/db/DBOper.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
 
$Permission = \User\Permission::P_System;
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
header("Content-type: text/html; charset=utf-8");
 
\Logging\CreateLogging("db.struct.php");
 
// 创建索引,如果表不存在则会自动创建表
$structInfo = array(
    "GameRoles" => array(
        array(
            array("Channel" => 1, "AccountID" => 1),
            array("‘unique" => true),
        )
    ),
 
    "GameServerInfo" => array(
        array(
            array("Channel" => 1, "ServerID" => 1),
            array("‘unique" => true),
        )
    ),
 
    "EventReportBug" => array(
        array(
            array("Channel" => 1, "Time" => -1),
            array(),
        )
    ),
 
    "GMTLog" => array(
        array(
            array("Permission" => 1, "OPTime" => -1),
            array(),
        )
    ),
 
    "UserToken" => array(
        array(
            array("Channel" => 1, "UserGuid" => 1),
            array(),
        )
    ),
 
    "PayOrder" => array(
        array(
            array("OrderID" => 1),
            array(),
        ),
        array(
            array("Channel" => 1, "ServerID" => 1, "State" => 1, "Createtime" => -1),
            array(),
        ),
        array(
            array("Channel" => 1, "State" => 1, "PayTime" => -1),
            array(),
        )
    ),
);
 
foreach ($structInfo as $collectionName => $indexList) {
    foreach ($indexList as $indexInfo) {
        $indexArray = $indexInfo[0];
        $indexParam = $indexInfo[1];
        $logInfo = "EnsureIndex => " . $collectionName . " index:" . print_r($indexArray, true) . " param:" . print_r($indexParam, true);
        if (\DBOper\EnsureIndex($collectionName, $indexArray, $indexParam)) {
            \Logging\LogInfo($logInfo);
            echo $logInfo, "<br/>";
        } else {
            echo "<font color='red'>";
            echo "Error: ", $logInfo, "<br/>";
            echo "</font>";
        }
    }
}
 
echo "OK", "<br/>";