Skip to content

Commit

Permalink
move views to "every upgrade" file (#3885)
Browse files Browse the repository at this point in the history
  • Loading branch information
crossan007 authored and DawoudIO committed Jan 12, 2018
1 parent a9327fa commit 5dab03b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/ChurchCRM/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function restoreDatabaseFromBackup($file)
FileSystemUtils::recursiveRemoveDirectory($restoreResult->backupRoot,true);
$restoreResult->UpgradeStatus = UpgradeService::upgradeDatabaseVersion();
SQLUtils::sqlImport(SystemURLs::getDocumentRoot() . '/mysql/upgrade/rebuild_nav_menus.sql', $connection);
SQLUtils::sqlImport(SystemURLs::getDocumentRoot() . '/mysql/upgrade/rebuild_views.sql', $connection);
//When restoring a database, do NOT let the database continue to create remote backups.
//This can be very troublesome for users in a testing environment.
SystemConfig::setValue('bEnableExternalBackupTarget', '0');
Expand Down
1 change: 1 addition & 0 deletions src/ChurchCRM/Service/UpgradeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static public function upgradeDatabaseVersion()
}
// always rebuild the menu
SQLUtils::sqlImport(SystemURLs::getDocumentRoot() . '/mysql/upgrade/rebuild_nav_menus.sql', $connection);
SQLUtils::sqlImport(SystemURLs::getDocumentRoot() . '/mysql/upgrade/rebuild_views.sql', $connection);

return true;
}
Expand Down
15 changes: 1 addition & 14 deletions src/mysql/upgrade/2.10.0.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
ALTER TABLE `events_event`
ADD COLUMN `event_publicly_visible` BOOLEAN DEFAULT FALSE AFTER `event_grpid`;

DROP VIEW IF EXISTS email_list;
CREATE VIEW email_list AS
SELECT fam_Email AS email, 'family' AS type, fam_id AS id FROM family_fam WHERE fam_email IS NOT NULL AND fam_email != ''
UNION
SELECT per_email AS email, 'person_home' AS type, per_id AS id FROM person_per WHERE per_email IS NOT NULL AND per_email != ''
UNION
SELECT per_WorkEmail AS email, 'person_work' AS type, per_id AS id FROM person_per WHERE per_WorkEmail IS NOT NULL AND per_WorkEmail != '';


DROP VIEW IF EXISTS email_count;
CREATE VIEW email_count AS
SELECT email, COUNT(*) AS total FROM email_list group by email;
ADD COLUMN `event_publicly_visible` BOOLEAN DEFAULT FALSE AFTER `event_grpid`;
12 changes: 12 additions & 0 deletions src/mysql/upgrade/rebuild_views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DROP VIEW IF EXISTS email_list;
CREATE VIEW email_list AS
SELECT fam_Email AS email, 'family' AS type, fam_id AS id FROM family_fam WHERE fam_email IS NOT NULL AND fam_email != ''
UNION
SELECT per_email AS email, 'person_home' AS type, per_id AS id FROM person_per WHERE per_email IS NOT NULL AND per_email != ''
UNION
SELECT per_WorkEmail AS email, 'person_work' AS type, per_id AS id FROM person_per WHERE per_WorkEmail IS NOT NULL AND per_WorkEmail != '';


DROP VIEW IF EXISTS email_count;
CREATE VIEW email_count AS
SELECT email, COUNT(*) AS total FROM email_list group by email;

0 comments on commit 5dab03b

Please sign in to comment.