1. You already have a production website
  2. Set up a development environment where you install TFA
  3. Drop the development environment's tables (drush sql-drop) so your database is clean
  4. Synchronize the production environment's database to your development environment (drush sql-sync)
  5. Sanitize the database (drush sql-sanitize)
  6. You get the error:
    ERROR 1146 (42S02) at line 1: Table 'tfa_totp_seed' doesn't exist
    Query failed.
    

The sanitize hook should check to see whether the table(s) exist (or maybe check to see that TFA is enabled) before running TRUNCATE.

Comments

pjcdawkins’s picture

Issue summary: View changes
pjcdawkins’s picture

Project: Two-factor Authentication (TFA) » TFA Basic plugins
Version: 7.x-2.x-dev » 7.x-1.x-dev

This should be for TFA Basic

coltrane’s picture

Status: Active » Needs review
StatusFileSize
new920 bytes

How about this? Also, @pjcdawkins do you know if this will work with prefixed tables?

coltrane’s picture

StatusFileSize
new919 bytes

Woops, #3 has a hanging character. Try this.

pjcdawkins’s picture

Status: Needs review » Needs work

Unfortunately that's not going to work

Fatal error: Call to undefined function db_table_exists() in [...] tfa_basic.drush.inc on line 13

I've created an issue for Drush here: https://github.com/drush-ops/drush/issues/1357

pjcdawkins’s picture

Priority: Normal » Minor

Greg Anderson has responded with a recommendation in the Drush issue
https://github.com/drush-ops/drush/issues/1357#issuecomment-97129724

It's a tricky solution to a relatively unimportant problem

greggles’s picture

I'd consider calling this "works as designed."

If it gets solved it should be solved in drush, IMO, since it affects all modules that implement sql_sync.

I think the "right" way to do this is with an update hook in a custom module on your dev site that enables tfa before the sanitize gets run.

pjcdawkins’s picture

I see your point but that "right way" would be pretty tricky, since a normal workflow is to sanitize as part of syncing, which is before updatedb runs.

And it's a bit anomalous that we are running SQL with no support for PDO etc. ... I could envision perhaps some improvements for Drush although I can see it's not going to be easy.

greggles’s picture

Yes, but the sanitize should be run by a codebase that matches the live site which would mean it doesn't include tfa yet, right?

pjcdawkins’s picture

Category: Bug report » Support request
Status: Needs work » Closed (works as designed)

The answer for these problems generally is probably:

instead of:

drush sql-sync --sanitize @remote @local
drush updatedb

do:

drush sql-sync @remote @local
drush updatedb
drush sql-sanitize
greggles’s picture

Yeah, that's one way. Also: http://www.knaddison.com/drupal/jenkins-drush-dropbox-easily-share-sanit... :)

Abbreviated:

On the server:

drush sql-sync @prod @scratch
drush sql-sanitize

On your local:

drush sql-sync @scratch @local
drush updb
fubarhouse’s picture

StatusFileSize
new808 bytes

Here's a patch which will help anybody who still runs into this ancient issue.
Truncating tables should never be attempted when the module isn't installed and/or the tables aren't there.