Fix formating and rewrite migration script
This commit is contained in:
parent
7d768ebd48
commit
e3cb6ca679
2 changed files with 55 additions and 26 deletions
|
@ -3,7 +3,36 @@
|
||||||
SET @schema_version = '22';
|
SET @schema_version = '22';
|
||||||
|
|
||||||
# Add field device_type to campaign_tracker
|
# Add field device_type to campaign_tracker
|
||||||
ALTER TABLE `campaign_tracker` ADD COLUMN `device_type` varchar(50) DEFAULT NULL AFTER `ip`;
|
|
||||||
|
# Create ALTER TABLE PROCEDURE
|
||||||
|
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
||||||
|
DELIMITER //
|
||||||
|
CREATE PROCEDURE alterbyregexp(`table_regexp` VARCHAR(255), `altertext` VARCHAR(255))
|
||||||
|
BEGIN
|
||||||
|
DECLARE done INT DEFAULT FALSE;
|
||||||
|
DECLARE tbl VARCHAR(255);
|
||||||
|
DECLARE curs CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = (SELECT DATABASE()) and table_name like table_regexp;
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||||
|
OPEN curs;
|
||||||
|
|
||||||
|
read_loop: LOOP
|
||||||
|
FETCH curs INTO tbl;
|
||||||
|
IF done THEN
|
||||||
|
LEAVE read_loop;
|
||||||
|
END IF;
|
||||||
|
SET @query = CONCAT('ALTER TABLE `', tbl, '`' , altertext);
|
||||||
|
PREPARE stmt FROM @query;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE curs;
|
||||||
|
END;
|
||||||
|
//
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
# Add field device_type to campaign_tracker
|
||||||
|
CALL alterbyregexp('campaign\_tracker%', 'ADD COLUMN `device_type` varchar(50) DEFAULT NULL AFTER `ip`');
|
||||||
|
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
||||||
|
|
||||||
# Footer section
|
# Footer section
|
||||||
LOCK TABLES `settings` WRITE;
|
LOCK TABLES `settings` WRITE;
|
||||||
|
|
|
@ -69,31 +69,31 @@
|
||||||
<!-- Default panel contents -->
|
<!-- Default panel contents -->
|
||||||
<div class="panel-heading">{{#if aggregated}}{{#translate}}Subscribers who clicked on a link:{{/translate}}{{else}}{{#translate}}Subscribers who clicked on this link:{{/translate}}{{/if}}</div>
|
<div class="panel-heading">{{#if aggregated}}{{#translate}}Subscribers who clicked on a link:{{/translate}}{{else}}{{#translate}}Subscribers who clicked on this link:{{/translate}}{{/if}}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{#if aggregated}}{{else}}
|
{{#if aggregated}}{{else}}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
||||||
<table class="table table-bordered table-hover data-piechart-ajax display nowrap">
|
<table class="table table-bordered table-hover data-piechart-ajax display nowrap">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
{{#translate}}Stats by country{{/translate}}
|
{{#translate}}Stats by country{{/translate}}
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
{{#translate}}Stats by device type{{/translate}}
|
{{#translate}}Stats by device type{{/translate}}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<div class="data-stats-pie-chart" data-topic-url="/campaigns/clicked" data-column="country" data-topic-id="{{id}}/{{link.id}}"></div>
|
<div class="data-stats-pie-chart" data-topic-url="/campaigns/clicked" data-column="country" data-topic-id="{{id}}/{{link.id}}"></div>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
<div class="data-stats-pie-chart" data-topic-url="/campaigns/clicked" data-column="device_type" data-topic-id="{{id}}/{{link.id}}"></div>
|
<div class="data-stats-pie-chart" data-topic-url="/campaigns/clicked" data-column="device_type" data-topic-id="{{id}}/{{link.id}}"></div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table data-topic-url="/campaigns/clicked" data-topic-id="{{id}}/{{link.id}}" data-sort-column="1" data-sort-order="asc" class="table table-bordered table-hover data-table-ajax display nowrap" width="100%" data-row-sort="0,1,1,1,1,1,0">
|
<table data-topic-url="/campaigns/clicked" data-topic-id="{{id}}/{{link.id}}" data-sort-column="1" data-sort-order="asc" class="table table-bordered table-hover data-table-ajax display nowrap" width="100%" data-row-sort="0,1,1,1,1,1,0">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue