14 Apr
2005
14 Apr
'05
6:01 a.m.
On Wed, 13 Apr 2005, Syscrusher wrote:
Good evening!
Goood morning!
Is there a well-behaved way to use Drupal's DB abstraction to find out if a table exists? I'm working on a migration feature, and need to be able to detect the existence of the table so that I can issue a user-friendly "you don't need to do this step" message if the table isn't there.
You could do "CREATE TABLE IF NOT EXISTS foo ...." and take out the user intervention completely. sed -e 's/CREATE TABLE \([a-z0-9_]*\)/CREATE TABLE IF NOT EXISTS \1/' \ < database.mysql > database-if-exists.mysql should create a proper Drupal db file with that clause for all tables. Cheers, Gerhard