久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區

標題: 分表升級失敗 [打印本頁]

作者: VRobin    時間: 2023-1-12 13:07
標題: 分表升級失敗
執行流程

?step=innodb&table=pre_forum_post_1

  1. (1075) Incorrect table definition; there can be only one auto column and it must be defined as a key
  2. ALTER TABLE forum_post_1 ENGINE=InnoDB;
復制代碼


get_scheme_update_sql 沒有對分表僅需處理



作者: 老周部落    時間: 2023-1-13 22:45
感謝您的反饋,我們寫個了修復,可以參考下。
具體得等測試,測試好了再合并。

  1. if (preg_match("/^pre_forum_post_(\\d+)$/i", $table)) {
  2.         logmessage("$table is special post table, need special alter.");
  3.         $sql = "ALTER TABLE ".str_replace(' pre_', ' '.$config['tablepre'], $table)." MODIFY COLUMN position INT unsigned NOT NULL DEFAULT \'0\'";
  4.         logmessage("RUNSQL ".$sql);
  5.         DB::query($sql);
  6.         logmessage("RUNSQL Success");
  7. } else {
  8.         $sql = get_innodb_scheme_update_sql($table);
  9.         logmessage("RUNSQL ".$sql);
  10.         DB::query($sql);
  11.         logmessage("RUNSQL Success");
  12. }
復制代碼

作者: sohigh    時間: 2023-4-16 16:45
本帖最后由 sohigh 于 2023-4-16 17:15 編輯
老周部落 發表于 2023-1-13 22:45
感謝您的反饋,我們寫個了修復,可以參考下。
具體得等測試,測試好了再合并。

$sql = "ALTER TABLE ".str_replace(' pre_', ' '.$config['tablepre'], $table)." MODIFY COLUMN position INT unsigned NOT NULL DEFAULT \'0\'";

這句沒執行
logmessage("$table is special post table, need special alter.");都沒顯示在日志里


作者: 天外飄仙    時間: 2023-4-16 17:15
sohigh 發表于 2023-4-16 16:45
pre_forum_post_1  的 position列已經變成了自增列,也是主鍵了。但是還報錯

(1075) Incorrect table defi ...

去掉 自增 就好了
作者: sohigh    時間: 2023-4-16 17:16
天外飄仙 發表于 2023-4-16 17:15
去掉 自增 就好了

是我搞錯了,問題是
$sql = "ALTER TABLE ".str_replace(' pre_', ' '.$config['tablepre'], $table)." MODIFY COLUMN position INT unsigned NOT NULL DEFAULT \'0\'";

這句沒執行
logmessage("$table is special post table, need special alter.");都沒顯示在日志里
作者: 天外飄仙    時間: 2023-4-16 17:24
sohigh 發表于 2023-4-16 17:16
是我搞錯了,問題是
$sql = "ALTER TABLE ".str_replace(' pre_', ' '.$config['tablepre'], $table)."  ...

自己 手動操作數據庫表 就好了……

Navicat連接數據庫,  表上 右鍵  設計 數據庫, 選中字段,  去除 自增勾選, 然后保存 就可以了
作者: sohigh    時間: 2023-4-19 21:17
天外飄仙 發表于 2023-4-16 17:24
自己 手動操作數據庫表 就好了……

Navicat連接數據庫,  表上 右鍵  設計 數據庫, 選中字段,  去除 自增 ...

我是這樣操作的,我想說怎么腳本沒用,是不是哪里錯了,你們再查下?方便后面的人




歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) Powered by Discuz! W1.0