目录

Upgrade Instruction (v0.7.1 to v0.7.2)

When you are ready to upgrade Cobub Razor from version 0.7.1 to version 0.7.2, following steps is required:

Step one: download the code of V0.7.2

1、Download the code of version 0.7.2 from https://github.com/cobub/razor , and you can get the razor-master.zip, unzip it to get razor-master folder, which contains the sdk and web folders.

2、Copy the web folder to the directory of your web site where you are ready to upgrade Cobub Razor (Note: web can not be the same name with Cobub Razor’s name of V0.7.1 or V0.7.2 ). To facilitate debugging, you can rename ”web” to “razor_v7.2“, and set the $ config ['base_url'] value to the ‘http://yoururl/razor_v7.2 ‘ in config.php which is under the application folder.

3、Copy the autoload.php and database.php of V0.7.1 under the directory of application\config\ to the diretory of application\config\ of V0.7.2, override these two files of V0.7.2, and replace $route['default_controller'] = “install/installation” to $route['default_controller'] = “report/home” of V0.7.2 in routes.php.

Step two: modify script files of database and data warehouse

Here, assume that your database is razor and data warehouse is razordw, and umsinstall_ is the table prefix of them.

1、Modify database

1)ci_sessions

property name property value changes
ip_address varchar(45) varchar(16)→ varchar(45)

sql

ALTER TABLE `razor.umsinstall_ci_sessions` 
CHANGE `ip_address` `ip_address` varchar(45); 

2)clientdata

property name property value changes
salt varchar(64) added

property `insertdate` adds index.(Attention:If the table has large datas, the execution time may be longe.)

sql

ALTER TABLE `razor.umsinstall_clientdata` 
ADD COLUMN `salt` varchar(64) DEFAULT NULL,INDEX(`insertdate`);

3) clientusinglog

property `insertdate`adds index.

sql

ALTER TABLE `razor.umsinstall_clientusinglog` 
ADD INDEX(`insertdate`);

4)errorlog

property `insertdate`adds index.

sql

ALTER TABLE `razor.umsinstall_errorlog` 
ADD INDEX(`insertdate`);

5)eventdata

property `insertdate`adds index.

sql语句:

ALTER TABLE `razor.umsinstall_eventdata` 
ADD INDEX(`insertdate`);

6) device_tag

property name property value changes
appkey varchar(64) productkey→appkey

sql

ALTER TABLE  `razor.umsinstall_device_tag` 
CHANGE  `productkey`  `appkey` varchar(64);

2、Modify the data warehouse

2.1、Add tables

1)sum_location

property name property value index
lid int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
location_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_location` (
  `lid`         int(11) NOT NULL AUTO_INCREMENT,
  `product_id`  int(11) NOT NULL,
  `date_sk`     int(11) NOT NULL,
  `location_sk` int(11) NOT NULL,
  `sessions`    int(11) NOT NULL DEFAULT '0',
  `newusers`    int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`lid`),
  UNIQUE KEY `index_location` (`product_id`,`date_sk`,`location_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

2)sum_devicebrand

property name property value index
did int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
devicebrand_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_devicebrand` (
  `did`            int(11) NOT NULL AUTO_INCREMENT,
  `product_id`     int(11) NOT NULL,
  `date_sk`        int(11) NOT NULL,
  `devicebrand_sk` int(11) NOT NULL,
  `sessions`       int(11) NOT NULL DEFAULT '0',
  `newusers`       int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`did`),
  UNIQUE KEY `index_devicebrand` (`product_id`,`date_sk`,`devicebrand_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

3)sum_deviceos

property name property value index
did int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
deviceos_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_deviceos` (
  `did`           int(11) NOT NULL AUTO_INCREMENT,
  `product_id`    int(11) NOT NULL,
  `date_sk`       int(11) NOT NULL,
  `deviceos_sk`   int(11) NOT NULL,
  `sessions`      int(11) NOT NULL DEFAULT '0',
  `newusers`      int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`did`),
  UNIQUE KEY `index_deviceos`(`product_id`,`date_sk`,`deviceos_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

4) sum_deviceresolution

property name property value index
did int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
deviceresolution_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_deviceresolution` (
  `did`                  int(11) NOT NULL AUTO_INCREMENT,
  `product_id`           int(11) NOT NULL,
  `date_sk`              int(11) NOT NULL,
  `deviceresolution_sk`  int(11) NOT NULL,
  `sessions`             int(11) NOT NULL DEFAULT '0',
  `newusers`             int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`did`),
  UNIQUE KEY 'index_deviceresolution'(`product_id`,`date_sk`,`deviceresolution_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

5)sum_devicesupplier

property name property value index
did int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
devicesupplier_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sq语句:

CREATE TABLE `razor.umsinstall_sum_devicesupplier` (
  `did`                int(11) NOT NULL AUTO_INCREMENT,
  `product_id`         int(11) NOT NULL,
  `date_sk`            int(11) NOT NULL,
  `devicesupplier_sk`  int(11) NOT NULL,
  `sessions`           int(11) NOT NULL DEFAULT '0',
  `newusers`           int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`did`),
  UNIQUE KEY `index_devicesupplier`(`product_id`,`date_sk`,`devicesupplier_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

6)sum_devicenetwork

property name property value index
did int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
devicenetwork_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_devicenetwork` (
  `did`              int(11) NOT NULL AUTO_INCREMENT,
  `product_id`       int(11) NOT NULL,
  `date_sk`          int(11) NOT NULL,
  `devicenetwork_sk` int(11) NOT NULL,
  `sessions`         int(11) NOT NULL DEFAULT '0',
  `newusers`         int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`did`),
  UNIQUE KEY `index_devicenetwork`(`product_id`,`date_sk`,`devicenetwork_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

7)sum_event

property name property name index
eid int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
product_id int(11) NOT NULL
date_sk int(11) NOT NULL
event_sk int(11) NOT NULL
sessions int(11) NOT NULL DEFAULT '0'
newusers int(11) NOT NULL DEFAULT '0'

sql

CREATE TABLE `razor.umsinstall_sum_event` (
  `eid`         int(11) NOT NULL AUTO_INCREMENT,
  `product_id`  int(11) NOT NULL,
  `date_sk`     int(11) NOT NULL,
  `event_sk`    int(11) NOT NULL,
  `total`       int(11) NOT NULL, 
  PRIMARY KEY (`eid`),
  UNIQUE KEY `product_sk`(`product_id`,`date_sk`,`event_sk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

8)deviceid_userid

property name property name index
did int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
deviceid varchar(128) NOT NULL
userid varchar(128) NOT NULL

sql

CREATE TABLE `razor.umsinstall_deviceid_userid` (
  `did`      int(11)      NOT NULL AUTO_INCREMENT,
  `deviceid` varchar(128) NOT NULL,
  `userid `  varchar(128) NOT NULL,
  PRIMARY KEY (`did`),
  UNIQUE KEY `deviceid`(`deviceid`,`userid`),
  KEY `userid` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

9)deviceid_pushid

property name property value index
did int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
deviceid varchar(128) NOT NULL
pushid varchar(128) NOT NULL

sql

CREATE TABLE `razor.umsinstall_deviceid_pushid` (
  `did`      int(11)      NOT NULL AUTO_INCREMENT,
  `deviceid`   varchar(128) NOT NULL,
  `pushid`  varchar(128) NOT NULL,
  PRIMARY KEY (`did`),
  UNIQUE KEY `deviceid`(`deviceid`,`pushid`)
  KEY `pushid` (`pushid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

2.2 Modify tables

1)dim_date

property name property name changes
datevalue Timestamp→Date

sql

ALTER TABLE `razordw.umsinstall_dim_date` 
CHANGE `datevalue` `datevalue` DATE NOT NULL;

2)dim_devicesupplier

property name property value changes
devicesupplier_name varchar(128) varchar(60)→ varchar(128)

sql

ALTER TABLE `razordw.umsinstall_dim_devicesupplier` 
CHANGE `devicesupplier_name` `devicesupplier_name` varchar(128);

3) fact_event

property `date_sk`add indexs

sql

ALTER TABLE `razordw.umsinstall_fact_event` 
ADD INDEX(`date_sk`,`product_sk`);

4)dim_date

Delete datevalue data before January 1, 2015 in the table.

sql

DELETE FROM umsinstall_dim_date
WHERE date_sk BETWEEN 1 AND 1827

3、Modify the stored procedures

Stored procedures: rundailyrundimrunfactrunmonthlyrunsum and runweekly

Steps:

1)you will get six sql script files under the directory of assets\sql of V0.7.2 : sp_rundaily.sqlsp_rundim.sqlsp_runfact.sqlsp_runmonthly.sqlsp_runsum.sql and sp_runweekly.sql.

2) modify table prefix

Modify the umsinstall_ in all sql scirpt files above to your own data warehouse’s table prefix, for example,your data warehouse table prefix “razordw_”;

Replace the “databaseprefix.umsdatainstall_” to “database.database’s table prefix”, for example, your database is cobubrazor,and database’s table prefix is razor_,the ”databaseprefix.umsdatainstall_” should be “cobubrazor.razor_“.

Step three: stop inserting data to database and pause the stored procedures.

Note: you need to have prepared all the relevant SQL scripts(i.e. all sql scripts in Step two).

Step four: delete all stored procedures in data warehouse.

Step five: execute the SQL scripts generated in Step two.

Note: Please backup the data of your database and data warehouse before you execute the sql scripts.

Step six:restart the database and data warehouse.

Before this step, you need to do the last thing :

Backup the directory of the previous web site(e.g web,which is the root directory of version 0.7.1),store it in a suitable place and named web-backup0.7.1, then delete web.

Change”razor_v7.2” to “web”(the name of V0.7.1),and set $config['base_url']= ‘http://yoururl/web’ in config.php.