TestLink の tcversions.tc_external_id を更新する

testprojects.name が日本語だと Migration しても tcversions.tc_external_id が入らない風味なので後から入れてみる。
普通なら Migration 前の ID は保持するべきだろうけど一から振り直してしまおう。
SQL 一発で変えられたりするんだろうか? よくわからんので Ruby を使う。
coLinux (192.168.0.5) に ある MySQLWindows (192.168.0.1) からアクセスする。

RubyMySQL へ接続

Ruby/MySQL から ruby-mysql-0.2.6.tar.gz を落として、展開して ruby setup.rb
適当な SQLMySQL へ接続。

require "mysql"
my = Mysql::new("192.168.0.5", "testlink", "password", "database")
res = my.query("select id from tcversions order by id")
res.each_hash do |row|
  p row["id"]
end

MySQL にアクセス拒否される。
/etc/mysql/my.cnf の bind-access = 127.0.0.1コメントアウト
メッセージは変わったけど、まだ拒否される

$ mysql -u root -p mysql
mysql> select user, Host from user;
+------------------+-----------+
| user             | Host      |
+------------------+-----------+
| root             | 127.0.0.1 |
|                  | localhost |
| debian-sys-maint | localhost |
| root             | localhost |
| testlink         | localhost |
|                  | ubuntu    |
| root             | ubuntu    |
+------------------+-----------+

Windows (192.168.0.1) からのアクセスが許可されていない。

mysql> grant all on database.* to testlink@192.168.0.1 identified by 'password';

今度は Client does not support authentication protocol requested by server; consider upgrading MySQL client (Mysql::Error) となった。
パスワードの形式を古くしてやれば良いみたいなので。

mysql> UPDATE user SET Password = OLD_PASSWORD('password') WHERE Host = '192.168.0.1' AND User = 'testlink';
mysql> FLUSH PRIVILEGES;

パスワードは後で設定しなした方がいいかな。

tcversions.tc_external_id の更新

testprojects.prefix を決めて入力しておく。
tcversions.id の順番に tcversions.tc_external_id へ testprojects.prefix + 「0 から 1 ずつカウントアップした数値」を入れていく。
最後に入れた数値を testprojects.tc_counter にも入れておく。
testprojects に複数のプロジェクトがあった場合は知らない。