Answers.Body: <p>It is possible to recreate the views using the following script. (It also recreates the triggers and stored functions that can have the same problem</p>
  
  <pre><code>&lt;?php
     civicrm_initialize();
     Civi::service('sql_triggers')-&gt;rebuild(null, false);
     CRM_Case_BAO_Case::createCaseViews();
  </code></pre>
  
  <p>Run the script with <code>drush scr &lt;script.php&gt;</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-24T09:49:04.197Z
Answers.LastActivityDate: 2019-04-24T09:49:04.197Z
Answers.UserDisplayName: Kainuk - CiviCooP
Body: <p>We have a website using CiviCRM that was recently switched from Drupal to WordPress as well as to a new server.</p>
  
  <p>Everything on the website is working properly and they have had no issues with CiviCRM.</p>
  
  <p>The problem: The websites and databases are backed up every night and the old backups are deleted upon completion of the backups. The CiviCRM database backup is failing because the database has 2 views (civicrm_view_case_activity_recent and civicrm_view_case_activity_upcoming) which have a "definer" which was carried over from the last server and does not exist on the new server. </p>
  
  <p>The question(s): Is there a way to redefine the definer without recreating those views?</p>
  
  <p>If not, is there code available to recreate those views? </p>
  
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-23T20:27:56.763Z
Comments.Text: Possible duplicate of [Migration error: “The user specified as a definer does not exist”](https://civicrm.stackexchange.com/questions/8854/migration-error-the-user-specified-as-a-definer-does-not-exist)
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-23T20:28:16.030Z
Comments.Text: There's an answer listed here that should help you: https://civicrm.stackexchange.com/a/20779/181
Comments.UserDisplayName: Demerit
Tags: <wordpress><database>
Title: CiviCRM database issue with views and the definer
ThreadText: # CiviCRM database issue with views and the definer
  
  (Asked by: username_0 on 2019-04-23)
  
  We have a website using CiviCRM that was recently switched from Drupal to WordPress as well as to a new server.
  
  Everything on the website is working properly and they have had no issues with CiviCRM.
  
  The problem: The websites and databases are backed up every night and the old backups are deleted upon completion of the backups. The CiviCRM database backup is failing because the database has 2 views (civicrm\_view\_case\_activity\_recent and civicrm\_view\_case\_activity\_upcoming) which have a "definer" which was carried over from the last server and does not exist on the new server.
  
  The question(s): Is there a way to redefine the definer without recreating those views?
  
  If not, is there code available to recreate those views?
  
  Thanks!
  
  **Tags:** wordpress, database
  
  > **Comments:**
  > **username_1**: Possible duplicate of [Migration error: “The user specified as a definer does not exist”](https://civicrm.stackexchange.com/questions/8854/migration-error-the-user-specified-as-a-definer-does-not-exist)  
  > **username_1**: There's an answer listed here that should help you: https://civicrm.stackexchange.com/a/20779/181  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-04-24. Score: 2
  
  It is possible to recreate the views using the following script. (It also recreates the triggers and stored functions that can have the same problem
  
  ```
  <?php
     civicrm_initialize();
     Civi::service('sql_triggers')->rebuild(null, false);
     CRM_Case_BAO_Case::createCaseViews();
  
  ```
  
  Run the script with `drush scr <script.php>`
  
  
  ---
  
  