SQL: Alt table prefix causes Structure to not detect duplicate tables #1025

Closed
linc opened this Issue Jul 11, 2011 · 1 comment

Projects

None yet

2 participants

@linc
Member
linc commented Jul 11, 2011

If you create a plugin that uses an alternate table prefix, it will not detect pre-existing tables with the same name because it will still use the GDN_ prefix in MySQLDriver::FetchTableSql.

 $Database = Gdn::Database();
 $Construct = $Database->Structure();
 $Construct->DatabasePrefix('alt_');

 $Construct->Table('example')
    ->Column('sample', 'varchar(40)')
    ->Set();

Throw that in a plugin Setup() and then enable, disable, and reenable again. The MySQLDriver is using $this->Database->DatabasePrefix to find the table rather than the copy of DatabasePrefix in the MySQLStructure object.

@tburry tburry was assigned Jul 11, 2011
@linc
Member
linc commented Jul 11, 2011

Workaround is to double-declare the prefix with

 $Database->DatabasePrefix ='alt_';
@tburry tburry closed this Aug 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment