練功房推薦書單

  • 猛虎出柙雙劍合璧版:最新 OCA / OCP Java SE 7 Programmer 專業認證
  • 流浪教師存零股存到3000萬
  • SCJP 6.0認證教戰手冊(第二版)Oracle Certified Professional Java Programmer(附光碟)
  • 小資女艾蜜莉:我的資產翻倍存股筆記
OLAT 5.2.3->6.0.0升級筆記  RSS feed
討論區首頁 » OLAT中文社群 OLAT Chinese Users Community
發表人 內容
andowson

七段學員
[Avatar]

註冊時間: 2007-01-02 22:20:40
文章: 704
來自: 台北
離線
這個週末花了兩天終於把現有的OLAT由5.2.3升級至6.0.0, 步驟如下:
cd ~/download
mv olat3 olat-5.2.3
wget http://www.olat.org/downloads/stable/OLAT-6.0.0.zip
unzip OLAT-6.0.0.zip
mv OLAT-6.0.0-PUBLIC-* olat3
cd olat3
sed -e "s/\/usr\/local\/opt\/olat\/olat3/\/home\/andowson\/download\/olat3/g" \
-e "s/\/usr\/local\/opt\/olat\/olatdata/\/home\/andowson\/www\/data\/olatdata/g" \
-e "1,$$s/myolat/andowson/g" \
-e "s/smtp.host=smtp.andowson.com/smtp.host=mail.andowson.com/" \
-e "s/\/usr\/local\/opt\/tomcat/\/var\/tomcat5/g" \
-e "1,$$s/net.sf.hibernate/org.hibernate/g" \
-e "48c\server.modjk.enabled=true" \
-e "95,117d" \
-e "1,$$s/#db/db/g" \
-e "s/instantMessaging.enable=false/instantMessaging.enable=true/" \
-e "s/instantMessaging.server.name=jabber.andowson.com/instantMessaging.server.name=www.andowson.com/" \
-e "s/instantMessaging.generateTestUsers=false/instantMessaging.generateTestUsers=true/" \
-e "s/instantMessaging.db.name=wildfire/instantMessaging.db.name=openfire/" \
-e "s/instantMessaging.db.user=wildfire/instantMessaging.db.user=olat/" \
-e "s/instantMessaging.db.pass=wildfire/instantMessaging.db.pass=olat/" build.properties.default > build.properties
ant install
ant jsmath
sudo /etc/init.d/tomcat stop
mv ~/www/olat /tmp/olat-5.2.3
cp -rf ~/download/olat3/webapp ~/www/olat
cp -rf ~/download/olat3/htdocs/* ~/www/olat
sed -i -e "13c\        <\!-- default session timeout -->" ~/www/olat/WEB-INF/web.xml
rm -rf ~/www/olat/WEB-INF/src
rm -rf ~/www/olat/WEB-INF/patchesSrc
rm -rf ~/www/olat/WEB-INF/test
cp /tmp/olat-5.2.3/WEB-INF/classes/hibernate.properties ~/www/olat/WEB-INF/classes/.
chgrp -R tomcat ~/www/olat
chgrp -R tomcat ~/www/data/olatdata
chmod 775 ~/www/olat/static
sudo -u postgres pg_dump olat > /tmp/olat.bak
sudo psql -U olat olat -f  /home/andowson/download/olat3/database/postgresql/alter_5_2_x_to_6_0_0.sql
sudo /etc/init.d/tomcat start

要注意的地方是原始碼內附的PostgreSQL升級SQL script有問題,字串應該用單引號來括起來,而不是用雙引號,另外有些欄位名稱也不對,必須調整後才能正常執行。好在我有先執行資料庫備份,再執行那條upgrade的SQL,不然這個SQL script只能執行一次,並且會把o_user裡面的一些欄位drop掉(這樣子你連執行第二次的機會都沒有了)。所以記住:要做任何系統升級之前,備份!備份!備份!
以下是我修改後的alter_5_2_x_to_6_0_0.sql:
--
-- new talbe to store the users properties
create table o_userproperty (
   fk_user_id int8 not null,
   propname varchar(255) not null,
   propvalue varchar(255),
   primary key (fk_user_id, propname)
);
create index propvalue_idx on o_userproperty (propvalue);
alter table o_userproperty add constraint FK4B04D83FD1A80C95 foreign key (fk_user_id) references o_user;

--
-- migrate data from old user table to new userproperty table
-- make sure you get this right the first time, you can not run this twice!
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'firstName', firstname from o_user where firstname IS NOT NULL AND firstname!='';
alter table o_user drop firstname; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'lastName', lastname from o_user where lastname IS NOT NULL AND lastname!='';
alter table o_user drop lastname; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'email', email from o_user where email IS NOT NULL AND email!='';
alter table o_user drop email; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'birthDay', birthday from o_user where birthday IS NOT NULL;
alter table o_user drop birthday; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'gender', gender from o_user where gender IS NOT NULL AND gender!='';
alter table o_user drop gender; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telMobile', telmobile from o_user where telmobile IS NOT NULL AND telmobile!='';
alter table o_user drop telmobile; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telOffice', teloffice from o_user where teloffice IS NOT NULL AND teloffice!='';
alter table o_user drop teloffice; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telPrivate', telprivate from o_user where telprivate IS NOT NULL AND telprivate!='';
alter table o_user drop telprivate; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalUserIdentifier', institutionaluseridentifier from o_user where institutionaluseridentifier IS NOT NULL AND institutionaluseridentifier!='';
alter table o_user drop institutionaluseridentifier; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalName', institutionalname from o_user where institutionalname IS NOT NULL AND institutionalname!='';
alter table o_user drop institutionalname; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalEmail', institutionalemail from o_user where institutionalemail IS NOT NULL AND institutionalemail!='';
alter table o_user drop institutionalemail; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'street', street from o_user where street IS NOT NULL AND street!='';
alter table o_user drop street; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'extendedAddress', extendedaddress from o_user where extendedaddress IS NOT NULL AND extendedaddress!='';
alter table o_user drop extendedaddress; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'poBox', pobox from o_user where pobox IS NOT NULL AND pobox!='';
alter table o_user drop pobox; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'zipCode', zipcode from o_user where zipcode IS NOT NULL AND zipcode!='';
alter table o_user drop zipcode; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'region', region from o_user where region IS NOT NULL AND region!='';
alter table o_user drop region; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'city', city from o_user where city IS NOT NULL AND city!='';
alter table o_user drop city; 

insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'country', country from o_user where country IS NOT NULL AND country!='';
alter table o_user drop country; 
--
-- end user properties migration

-- new table to store the read messages, migrate the read messages from the o_property to the new table
create table o_readmessage (
	id int8 not null, 
	lastmodified timestamp not null,
    creationdate timestamp,
	identity_id int8 not null, 
	forum_id int8 not null, 
	message_id int8 not null, 
	primary key (id));
create index identity_forum_idx on o_readmessage(identity_id, forum_id);

insert into o_readmessage (id, lastmodified, creationdate, identity_id, forum_id, message_id) select id, lastmodified, creationdate, identity, resourcetypeid, longvalue from o_property where category='rvst';
delete from o_property where category='rvst';

-- end read messages

-- update fontsize to new relative style
update o_user set fontsize = '110' where fontsize = 'large';
update o_user set fontsize = '100' where fontsize = 'normal';
update o_user set fontsize = '90' where fontsize = 'small';
-- end fontsize update
 檔案名稱 alter_5_2_x_to_6_0_0.sql [Disk] 下載
 描述 修正後的postgresql升級SQL Script
 檔案大小 5 Kbytes
 下載次數:  9 次


分享經驗 累積智慧
[WWW] [MSN]
 
討論區首頁 » OLAT中文社群 OLAT Chinese Users Community
前往: