= = = '''How to update bbmri app''' = == Export war & mysql file == 1. Run the app on your molgenis-legacy workspace (using tomcat, not standalone) 1. Export the war file 1. In eclipse: File--> export --> Web --> war file 1. The database is updated as follows: apply the mysql changes that you have made locally to the database on the server, so that you have the latest version of data for the server and the changes you want applied there. About the database changes you need to track them in a migration a file like one in the end of this document. == Quick tutorial == 1) Copy the mysqldump from the live server to the test server [[BR]]2) Deploy the new war file on the testserver[[BR]] 2.1) Check if there are errors according to changes in the model. There are 2 ways: * compare the mysql from the live and the testserver * check in the application if there are errors 2.2) If there are changes, make the migration script[[BR]] '''Deploy to server''' 1. As also listed here: http://www.molgenis.org/wiki/MolgenisServers the '''test server''' is at molgenis35(https://molgenis35.target.rug.nl/biobanks/) and the '''production server''' at molgenis14(https://catalogue.bbmri.nl/biobanks/) . 1. First deploy at test server, notify [mailto:david.van.enckevort@nbic.nl david.van.enckevort AT nbic.nl]. He will notify BBMRI office, they will review the changes and if everything is ok proceed to updating bbmri production server. 1. Deploy at test server: molgenis35 (Take a look here also http://www.molgenis.org/wiki/SopCreateMolgenisVM#SopDeploymentForDevs ) : 1. Ask credentials for molgenis35/molgenis14 from Pieter or Morris. === create migration script according to data in live server  === 1. If you know the exact changes of the database, compared to the old version in live server, then the migration script is the commands that synchornize the two versions. 1. You can compare the mysql dump files between the live and the local version. This is easier if you dump only the schemas (not the data) . 1. First ssh to molgenis14 1. create a dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/bbmriDBlive.mysql 1. create a local dump file: mysqldump --no-data, -d bbmri -u molgenis –pmolgenis > ~/databaseDumps/bbmriDBlocal.mysql 1. diff bbmriDBlive.mysql bbmriDBlocal.mysql === copy war file & migration script from your computer to test server === 1. Copy the war file and the mysql migration script from your computer to the server as follows: 1. scp .war molgenis@molgenis35.target.rug.nl:./ 1. scp molgenis@molgenis35.target.rug.nl:./ === Export data from LIVE server === 1. Ssh to the server: * ssh !molgenis@molgenis14.target.rug.nl 1. Get data: * mysqldump bbmri -u molgenis –p > ~/databaseDumps/bbmriDB.mysql === Copy data from LIVE server to your computer === 1. scp molgenis@molgenis14.target.rug.nl:./databaseDumps/bbmriDB.mysql ./mysqlLIVEdata.mysql === Copy data from your computer to test server === 1. scp ./mysqlLIVEdata.mysql molgenis@molgenis35.target.rug.nl:./databaseDumps/mysqlLIVEdata.mysql === Deploy at test server === 1. Ssh to the server: * ssh !molgenis@molgenis35.target.rug.nl * You are now at /srv/molgenis/ where your files where copied. === Backup === 1. '''BACKUP your DATABASE FIRST''': * mysqldump bbmri -u molgenis –pmolgenis > ~/databaseDumps/bbmriDB.mysql * Check the dumbed file if it is not just an error file … === Insert the data from live server to test server === compare the sql file from test server with the live server. then make a migrationscript and insert this tables into testserver === * mysql -u molgenis -pmolgenis bbmri < 29Maydump.mysql === === === Apply migration steps: === * mysql -u molgenis –pmolgenis * use bbmri * * '''Backup & replace the war file on server''': * The war file is in /usr/share/tomcat6/webapps/biobanks.war * cp /usr/share/tomcat6/webapps/biobanks.war ~/warFiles/ * Delete the old *.war (Do NOT stop tomcat; leave it running): rm /usr/share/tomcat6/webapps/biobanks.war * Wait a few seconds; Tomcat will notice the *.war is gone and then it will remove the unzipped folder. * Copy the the new *.war to the webapps dir; Tomcat will detect the new *.war and unzip it. * cp .war /usr/share/tomcat6/webapps/biobanks.war * You can check the tomcat & mysql service with: * sudo service tomcat6 status * sudo service mysqld status * Check your deployment at: https://molgenis35.target.rug.nl/biobanks/ == ''' The same steps apply to the production server molgenis14 . ''' == == '''Appendix ''' == * Find miscellaneous issues here: http://www.molgenis.org/wiki/DespoinaLog * An old example migration file: {{{ CREATE TABLE !`BiobankSubCategory` (   !`id` int(11) NOT NULL,   PRIMARY KEY (!`id`),   CONSTRAINT !`biobanksubcategory_ibfk_1` FOREIGN KEY (!`id`) REFERENCES !`OntologyTerm` (!`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;     INSERT INTO !BiobankSubCategory (id) SELECT id FROM !BiobankCategory WHERE id  NOT IN ("281", "284", "285") ;   CREATE TABLE !BiobankPersonRole (             id INTEGER NOT NULL             , PRIMARY KEY(id) );   alter table !OntologyTerm modify   column !__Type enum('!OntologyTerm','!PersonRole','Species','!AlternateId','!BiobankCategory','!BiobankTopic','!BiobankDataType', '!BiobankSubCategory','!BiobankPersonRole');     ALTER TABLE Biobank DROP FOREIGN KEY biobank_ibfk_5;   ALTER TABLE !BiobankSubCategory ADD FOREIGN KEY (id) REFERENCES !OntologyTerm (id) ON DELETE CASCADE;   ALTER TABLE !`BiobankSubCategory`  ADD CONSTRAINT !`biobank_ibfk_5`     FOREIGN KEY (!`id`) REFERENCES !OntologyTerm (id) ON DELETE CASCADE; this exists already from his creation)   ALTER TABLE Biobank ADD FOREIGN KEY (!SubCategory) REFERENCES !BiobankSubCategory (id) ON DELETE RESTRICT;   ALTER TABLE !`Biobank`  ADD CONSTRAINT !`biobank_ibfk_885`     FOREIGN KEY (!`SubCategory`) REFERENCES !BiobankSubCategory (id)  ON DELETE CASCADE;       DELETE FROM !BiobankCategory WHERE id  NOT IN ("281", "284", "285") ;         ALTER TABLE !BiobankPersonRole ADD FOREIGN KEY (id) REFERENCES !PersonRole (id) ON DELETE CASCADE;     ALTER TABLE !`BiobankPersonRole`  ADD CONSTRAINT !`BiobankPersonRole_ibfk_33`     FOREIGN KEY (!`id`) REFERENCES !PersonRole (id)  ON DELETE CASCADE;   UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='282'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='283'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='286'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='287'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='288'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='289'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='290'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='291'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='292'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='293'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='295'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='296'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='297'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='298'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='564'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='299'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='294';       select * from !OntologyTerm where name="Software Engineer"; delete from !OntologyTerm where id=561; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(561);   select * from !OntologyTerm where name="coordinator"; delete from !OntologyTerm where id=593; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(277);   select * from !OntologyTerm where name="postdoc"; delete from !OntologyTerm where id=594;  select * from !BiobankPersonRole; insert into !BiobankPersonRole values(278);   select * from !OntologyTerm where name="administrator"; delete from !OntologyTerm where id=595; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(279);     select * from !OntologyTerm where name="IT responsible"; delete from !OntologyTerm where id=596; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(280);   //how to make values of Person Role appear in ui , you have to delete some old from DB :   create a new Coordinator Role in the ui and remember the id 591 (select * from !PersonRole; --> the latest one, or check from ui ) correct the Person table with t he new entry(that is not show in the ui) :   update Person set Roles=591 where Roles=277   delete the old one :    delete from !PersonRole where id=277; delete from  !BiobankPersonRole  where id=277; delete from !OntologyTerm  where id=277;   repeat the same step for all of them     COMMIT;   =========================================================== !SubCategory biobank_ibfk_1   CONSTRAINT !`biobank_ibfk_5` FOREIGN KEY (!`SubCategory`) REFERENCES !`BiobankSubCategory` (!`id`)   CONSTRAINT !`biobank_ibfk_5` FOREIGN KEY (!`SubCategory`) REFERENCES !`BiobankSubCategory` (!`id`),     CREATE TABLE !BiobankPersonRole (             id INTEGER NOT NULL             , PRIMARY KEY(id) );   ALTER TABLE !BiobankPersonRole ADD FOREIGN KEY (id) REFERENCES !PersonRole (id) ON DELETE CASCADE;   alter table !OntologyTerm modify   column !__Type enum('!OntologyTerm','!PersonRole','Species','!AlternateId','!BiobankCategory','!BiobankTopic','!BiobankDataType', '!BiobankSubCategory','!BiobankPersonRole');   UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='282'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='283'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='286'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='287'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='288'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='289'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='290'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='291'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='292'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='293'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='295'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='296'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='297'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='298'; UPDATE !OntologyTerm  SET !__Type="!BiobankSubCategory" WHERE id='564';   /*below we resolve the problem of duplicate entries in ontology term for !PersonRole*/   select * from !OntologyTerm where name="Software Engineer"; delete from !OntologyTerm where id=561; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(561);   select * from !OntologyTerm where name="coordinator"; delete from !OntologyTerm where id=593; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(277);   select * from !OntologyTerm where name="postdoc"; delete from !OntologyTerm where id=594;  select * from !BiobankPersonRole; insert into !BiobankPersonRole values(278);   select * from !OntologyTerm where name="administrator"; delete from !OntologyTerm where id=595; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(279);     select * from !OntologyTerm where name="IT responsible"; delete from !OntologyTerm where id=596; select * from !BiobankPersonRole; insert into !BiobankPersonRole values(280);     COMMIT; }}}