Answers.Body: <p>This ended up being a case of looking at the wrong database.  The version/build/schema numbers for the correct database were all in sync.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-22T16:08:21.710Z
Answers.LastActivityDate: 2015-01-22T16:08:21.710Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have had a custom console command running fine for several months now which sent out reminder emails to users when there accounts are about to expire.</p>
  
  <p>After the latest Craft update (I believe) it stopped working. Here is the error:</p>
  
  <pre><code>CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054
  Unknown column 'users.locked' in 'field list'
  exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.locked' in 'field list'' in CDbCommand.php:543
  </code></pre>
  
  <p>The lines of code from the plugin service which cause the error are:</p>
  
  <pre><code>$user_criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
  
  $user_criteria-&gt;userExpiryDate = date('Y-m-d',strtotime("+7 days"));
  
  $users = $user_criteria-&gt;find();
  </code></pre>
  
  <p>Basically it fails when running the find() method.</p>
  
  <p>Strangely I haven't managed to replicate the error on my local machine.</p>
  
  <p>Does anyone have any idea what might be causing this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-16T17:53:28.447Z
Comments.Text: Do you have a 'locked' column in your craft_users table? That table's schema changed within the last several months. Maybe your database and your code are out of sync?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-19T10:01:31.247Z
Comments.Text: Hi Brad, I've just checked the table and there is no locked column. What would be the best way to fix this problem?
Comments.UserDisplayName: Dave Coggins
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-19T18:50:14.830Z
Comments.Text: Check the schemaVersion and build in your `craft/app/Info.php` and file and compare that to you the schemaVersion and build in the `craft_info` table in the database. If those don't match then your database schema is out of sync with the code you're running.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T03:04:31.930Z
Comments.Text: On the live site in the Info.php it is on 2.3.1 but on the database it is 2.1.2. Somebody else applied the update on the live site without my knowledge so I'm not sure whether it was successful. When I backed up the live database and imported it to my local server the schemas matched (both on 2.3.1) which I can't seem to explain. Any suggestions on how to resolve this issue?
Comments.UserDisplayName: Dave Coggins
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T17:55:18.383Z
Comments.Text: What's the build number in Info.php and the database?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T23:49:01.127Z
Comments.Text: In info.php the build is 2625 and in the database it is 2569
Comments.UserDisplayName: Dave Coggins
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-20T23:53:28.410Z
Comments.Text: When you go to the control panel, are you not prompted to complete an upgrade?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-21T01:01:58.543Z
Comments.Text: No, which is what I would expect to happen and has happened in the past. I have also tried clicking check for updates and it says there is no more updates
Comments.UserDisplayName: Dave Coggins
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-21T01:03:58.133Z
Comments.Text: If you want to send some CP/FTP/database credentials over to support@buildwithcraft.com, we can look into why it's not prompting to update.
Comments.UserDisplayName: Brad Bell
Tags: <plugin-development><database><updates>
Title: Console command runing from Cron job failing after Craft update
ThreadText: # Console command runing from Cron job failing after Craft update
  
  (Asked by: username_0 on 2015-01-16)
  
  I have had a custom console command running fine for several months now which sent out reminder emails to users when there accounts are about to expire.
  
  After the latest Craft update (I believe) it stopped working. Here is the error:
  
  ```
  CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054
  Unknown column 'users.locked' in 'field list'
  exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.locked' in 'field list'' in CDbCommand.php:543
  
  ```
  
  The lines of code from the plugin service which cause the error are:
  
  ```
  $user_criteria = craft()->elements->getCriteria(ElementType::User);
  
  $user_criteria->userExpiryDate = date('Y-m-d',strtotime("+7 days"));
  
  $users = $user_criteria->find();
  
  ```
  
  Basically it fails when running the find() method.
  
  Strangely I haven't managed to replicate the error on my local machine.
  
  Does anyone have any idea what might be causing this?
  
  **Tags:** plugin-development, database, updates
  
  > **Comments:**
  > **username_1**: Do you have a 'locked' column in your craft_users table? That table's schema changed within the last several months. Maybe your database and your code are out of sync?  
  > **username_0**: Hi username_1, I've just checked the table and there is no locked column. What would be the best way to fix this problem?  
  > **username_1**: Check the schemaVersion and build in your `craft/app/Info.php` and file and compare that to you the schemaVersion and build in the `craft_info` table in the database. If those don't match then your database schema is out of sync with the code you're running.  
  > **username_0**: On the live site in the Info.php it is on 2.3.1 but on the database it is 2.1.2. Somebody else applied the update on the live site without my knowledge so I'm not sure whether it was successful. When I backed up the live database and imported it to my local server the schemas matched (both on 2.3.1) which I can't seem to explain. Any suggestions on how to resolve this issue?  
  > **username_1**: What's the build number in Info.php and the database?  
  > **username_0**: In info.php the build is 2625 and in the database it is 2569  
  > **username_1**: When you go to the control panel, are you not prompted to complete an upgrade?  
  > **username_0**: No, which is what I would expect to happen and has happened in the past. I have also tried clicking check for updates and it says there is no more updates  
  > **username_1**: If you want to send some CP/FTP/database credentials over to support@buildwithcraft.com, we can look into why it's not prompting to update.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-01-22. Score: 0 | Accepted answer
  
  This ended up being a case of looking at the wrong database. The version/build/schema numbers for the correct database were all in sync.
  
  
  ---
  
  