Drupalは優れたCMSであり、DBとしてMySQLとPostgresqlの両者で動作できるようになっている。
しかし歴史的な経緯により、MySQLでの動作のほうが問題が少ない。
というのはDrupalでサイトを構築する場合、数多くのモジュールを使用して、機能追加を行っていくが、それでモジュールもDBへのアクセスを行う。
モジュールによっては、ロジックの中でMySQLでしか動作しないSQL処理を行っているものが多数あります。
残念ながら当初はそういった点を見切れず、このサイトではDrupal+Postgresqlを選択して稼動しています。
そのため、いくつかのモジュールで問題が出ることも多数。一度サイトが稼動すると、
なかなかデータベースの移行もままならず、当面はむしろ動かしたいモジュールをPostgresqlへ対応させていくこととします。
そんな、MySQLでしか動かないモジュールの一つがmultipingモジュール(http://drupal.org/project/multiping)
調査したところ、multipingモジュールでは、install時のSQLスキーマと初期データ展開に若干不具合があります。ので修正パッチを作成しました。
Written by Takashi Ikebe(iktaka@gmail.com)
--- multiping.install.org 2008-08-21 15:33:20.000000000 +0900
+++ multiping.install 2008-08-21 16:29:54.000000000 +0900
@@ -1,27 +1,53 @@
<?php
function multiping_schema() {
- $schema['multiping'] = array(
- 'fields' => array(
- 'id' => array('type'=>'serial', 'unsigned'=>TRUE, 'not null'=>TRUE),
- 'name' => array('type'=>'varchar', 'length'=>100, 'not null'=>TRUE),
- 'url' => array('type'=>'varchar', 'length'=>255, 'not null'=>TRUE),
- 'method' => array('type'=>'varchar', 'length'=>50),
- 'lastping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
- 'whentoping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>1),
- 'submitmainrss' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
- 'voc' => array('type'=>'text', 'length'=>4000),
- 'nodetypes' => array('type'=>'text', 'length'=>4000),
- 'failcount' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
- ),
- 'primary key' => array('id'),
- );
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $schema['multiping'] = array(
+ 'fields' => array(
+ 'id' => array('type'=>'serial', 'unsigned'=>TRUE, 'not null'=>TRUE),
+ 'name' => array('type'=>'varchar', 'length'=>100, 'not null'=>TRUE),
+ 'url' => array('type'=>'varchar', 'length'=>255, 'not null'=>TRUE),
+ 'method' => array('type'=>'varchar', 'length'=>50),
+ 'lastping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ 'whentoping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>1),
+ 'submitmainrss' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ 'voc' => array('type'=>'text', 'length'=>4000),
+ 'nodetypes' => array('type'=>'text', 'length'=>4000),
+ 'failcount' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ ),
+ 'primary key' => array('id'),
+ );
+ case 'pgsql':
+ $schema['multiping'] = array(
+ 'fields' => array(
+ 'id' => array('type'=>'serial', 'unsigned'=>TRUE, 'not null'=>TRUE),
+ 'name' => array('type'=>'varchar', 'length'=>100, 'not null'=>TRUE),
+ 'url' => array('type'=>'varchar', 'length'=>255, 'not null'=>TRUE),
+ 'method' => array('type'=>'varchar', 'length'=>50),
+ 'lastping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ 'whentoping' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>1),
+ 'submitmainrss' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ 'voc' => array('type'=>'text'),
+ 'nodetypes' => array('type'=>'text'),
+ 'failcount' => array('type'=>'int', 'unsigned'=>TRUE, 'default'=>0),
+ ),
+ 'primary key' => array('id'),
+ );
+ }
return $schema;
}
function multiping_install() {
drupal_install_schema('multiping');
- db_query("INSERT INTO {multiping} (id,name,url,method,lastping,whentoping,submitmainrss,voc,nodetypes,failcount) VALUES (1, 'Ping-o-matic', 'http://rpc.pingomatic.com', 'weblogUpdates.ping', 0, 9, 1, 'N;', 'N;', 0);");
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ db_query("INSERT INTO {multiping} (id,name,url,method,lastping,whentoping,submitmainrss,voc,nodetypes,failcount) VALUES (1, 'Ping-o-matic', 'http://rpc.pingomatic.com', 'weblogUpdates.ping', 0, 9, 1, 'N;', 'N;', 0);");
+ case 'pgsql':
+ db_query("INSERT INTO {multiping} (name,url,method,lastping,whentoping,submitmainrss,voc,nodetypes,failcount) VALUES ('Ping-o-matic', 'http://rpc.pingomatic.com', 'weblogUpdates.ping', 0, 9, 1, 'N;', 'N;', 0);");
+ }
}
function multiping_uninstall() {
このパッチはmultiping-6.x.-1.x-dev(2008-Aug-5)版を対象としています。multiping.installファイルへ適応することで、うまくpostgresqlでもmultipingモジュールが動作します。
このパッチは、drupalの本家にも投稿しておきました。
Drupal / Postgresqlで運用している人はそんなにいないと思いますが、お役に立てれば。