• R/O
  • HTTP
  • SSH
  • HTTPS

WebChat: コミット

チャットシステム


コミットメタ情報

リビジョンbe62e239c93c4d89b35b2b794ae2772116089845 (tree)
日時2014-05-31 18:55:29
作者gdkhd812 <jbh03215@hotm...>
コミッターgdkhd812

ログメッセージ

name_hashは被る可能性があるので、primaryではなくindexを指定するようにした

変更サマリ

差分

--- a/configure.js
+++ b/configure.js
@@ -61,7 +61,6 @@
6161 name : "名前(ハッシュ)",
6262 type : "unsignednumber",
6363 length : 4,
64- primary : true,
6564 visible : false,
6665 visible_edit : false,
6766 visible_registor : false,
--- a/init.js
+++ b/init.js
@@ -40,15 +40,17 @@ module.exports = function(callback){
4040 }else{
4141 throw "lastmodifiedが存在しません";
4242 }
43+
44+ var Sequelize = require("sequelize");
45+ var pool = new Sequelize(config.db_name, config.db_user, config.db_password,{
46+ host:config.db_host,
47+ port:config.db_port
48+ });
49+
4350 var fs = require("fs");
51+
4452 async.waterfall([
4553 function(next){
46- var Sequelize = require("sequelize");
47- var pool = new Sequelize(config.db_name, config.db_user, config.db_password,{
48- host:config.db_host,
49- port:config.db_port
50- });
51-
5254 var query = GetCreateQuery(Sequelize,config.alias,"profilelist");
5355 var profilelist = pool.define("profilelist",query);
5456 module.exports.GetProfileColletion = profilelist;
@@ -62,7 +64,6 @@ module.exports = function(callback){
6264 type:{
6365 type : "text",
6466 length : 1,
65- primary : true,
6667 },
6768 };
6869 var query = GetCreateQuery(Sequelize,def,"ipbanlist");
@@ -95,25 +96,33 @@ module.exports = function(callback){
9596 },
9697 function(exists,next){
9798 if(exists)
98- next(null);
99+ next(true);
99100 else
100101 fs.open("inited","a",function(err,fd){
101102 fs.closeSync(fd);
102-
103- module.exports.GetProfileColletion.drop();
104- module.exports.GetProfileColletion.sync();
105-
106- module.exports.GetIpBanColletion.drop();
107- module.exports.GetIpBanColletion.sync();
108-
109- module.exports.GetRoomInfomation.drop();
110- module.exports.GetRoomInfomation.sync();
111-
112103 next(null);
113104 });
105+ },
106+ function(next){
107+ module.exports.GetProfileColletion.sync({force:true}).done(next);
108+ },
109+ function(result,next){
110+ pool.getQueryInterface().addIndex(
111+ module.exports.GetProfileColletion.tableName,
112+ ["name_hash"]
113+ ).done(next);
114+ },
115+ function(result,next){
116+ module.exports.GetIpBanColletion.sync({force:true}).done(next);
117+ },
118+ function(result,next){
119+ module.exports.GetRoomInfomation.sync({force:true}).done(next);
114120 }
115121 ],function(err){
116- callback(err);
122+ if(err)
123+ callback(null);
124+ else
125+ callback(err);
117126 });
118127 }
119128
@@ -156,7 +165,7 @@ function GetCreateQuery(Sequelize,def,tablename)
156165 }
157166 if(typeof(def[key].isnotempty) != "undefined" && def[key].isnotempty)
158167 option["allowNull"] = true;
159- else if(typeof(def[key].primary) != "undefined" && def[key].primary)
168+ if(typeof(def[key].primary) != "undefined" && def[key].primary)
160169 option["primaryKey"] = true;
161170 result[key] = option;
162171 }
--- a/init.sql
+++ b/init.sql
@@ -3,6 +3,7 @@ grant select,
33 delete,
44 create,
55 drop,
6+ index,
67 update on *.* to user identified by 'user';
78 flush privileges;
89 CREATE DATABASE IF NOT EXISTS webchat DEFAULT CHARSET=utf8;
旧リポジトリブラウザで表示