This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalised the database, and refactored the reporting to allow it to …
…support multiple dbs.
- Loading branch information
1 parent
4b74b34
commit e79ffc5
Showing
10 changed files
with
399 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,55 @@ | ||
ALTER TABLE `squabble_visitors` | ||
ADD INDEX `idx_test_name` (`test_name` ASC) ; | ||
|
||
delete | ||
from | ||
squabble_combinations | ||
where | ||
visitor_id NOT IN (select squabble_visitors.id from squabble_visitors); | ||
|
||
ALTER TABLE `squabble_combinations` | ||
ADD CONSTRAINT `fk_combination_visitor_id` | ||
FOREIGN KEY (`visitor_id` ) | ||
REFERENCES `squabble_visitors` (`id` ) | ||
ON DELETE RESTRICT | ||
ON UPDATE RESTRICT | ||
, ADD INDEX `fk_combination_visitor_id` (`visitor_id` ASC) ; | ||
|
||
ALTER TABLE `squabble_conversions` | ||
ADD CONSTRAINT `fk_conversion_visitor_id` | ||
FOREIGN KEY (`visitor_id` ) | ||
REFERENCES `squabble_visitors` (`id` ) | ||
ON DELETE RESTRICT | ||
ON UPDATE RESTRICT | ||
, ADD INDEX `fk_conversion_visitor_id` (`visitor_id` ASC) ; | ||
|
||
ALTER TABLE `squabble_conversions` | ||
CHANGE `conversion_revenue` `conversion_value` double; | ||
|
||
ALTER TABLE `squabble_conversions` | ||
ADD `conversion_units` DOUBLE AFTER `conversion_value`; | ||
/* | ||
Copyright 2011 Ezra Parker, Josh Wines, Mark Mandel | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
Squabble Database Create Script (MySQL with InnoDB) | ||
*/ | ||
|
||
ALTER TABLE `squabble_visitors` ADD COLUMN `flat_combination` VARCHAR(1000) NOT NULL AFTER `test_name` | ||
, ADD INDEX `idx_flat_combination` (`flat_combination` ASC) ; | ||
|
||
drop table if exists temp_visitor_data ; | ||
|
||
create table temp_visitor_data ( | ||
`id` char(35) , | ||
flat_combination varchar(1000) | ||
,PRIMARY KEY (`id`) | ||
) | ||
; | ||
|
||
insert into temp_visitor_data | ||
(id, flat_combination) | ||
SELECT | ||
squabble_visitors.id, | ||
GROUP_CONCAT(squabble_combinations.variation_name ORDER BY squabble_combinations.section_name) AS combination | ||
FROM | ||
squabble_visitors | ||
INNER JOIN | ||
squabble_combinations | ||
ON squabble_combinations.visitor_id = squabble_visitors.id | ||
group by | ||
squabble_visitors.id | ||
; | ||
|
||
update | ||
squabble_visitors, temp_visitor_data | ||
set | ||
squabble_visitors.flat_combination = temp_visitor_data.flat_combination | ||
where | ||
squabble_visitors.id = temp_visitor_data.id; | ||
and | ||
squabble_visitors.flat_combination is null | ||
|
||
drop table if exists temp_visitor_data ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.