Update fails with MS SQL Server
The upgrade fails with the following message (Tested with 5.x->6.0 as well as 6.0.0 -> 6.0.0a):
exception occurred while executing 'CREATE TABLE [oc_appconfig] ([appid] NVARCHAR(32) DEFAULT '' NOT NULL, [configkey] NVARCHAR(64) DEFAULT '' NOT NULL, [configvalue] VARCHAR(MAX) NULL, PRIMARY KEY ([appid], [configkey]))': SQLSTATE[42S01]: [Microsoft][SQL Server Native Client 11.0][SQL Server]In der Datenbank ist bereits ein Objekt mit dem Namen 'oc_appconfig' vorhanden.
The log says:
{"app":"core","message":"Failed to update database structure (exception 'PDOException' with message 'SQLSTATE[42S01]: [Microsoft][SQL Server Native Client 11.0][SQL Server]In der Datenbank ist bereits ein Objekt mit dem Namen 'oc_appconfig' vorhanden.' in C:\\inetpub\\owncloud\\3rdparty\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Connection.php:742
Stack trace:
#0 [internal function]: PDO->query('CREATE TABLE [o...')
#1 C:\\inetpub\\owncloud\\3rdparty\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Connection.php(742): call_user_func_array(Array, Array)
#2 C:\\inetpub\\owncloud\\lib\\private\\db\\mdb2schemamanager.php(152): Doctrine\\DBAL\\Connection->query('CREATE TABLE [o...')
#3 C:\\inetpub\\owncloud\\lib\\private\\db\\mdb2schemamanager.php(91): OC\\DB\\MDB2SchemaManager->executeSchemaChange(Object(Doctrine\\DBAL\\Schema\\SchemaDiff))
#4 C:\\inetpub\\owncloud\\lib\\private\\db.php(376): OC\\DB\\MDB2SchemaManager->updateDbFromStructure('C:\/inetpub\/ownc...')
#5 C:\\inetpub\\owncloud\\lib\\private\\updater.php(106): OC_DB::updateDbFromStructure('C:\/inetpub\/ownc...')
#6 C:\\inetpub\\owncloud\\core\\ajax\\update.php(34): OC\\Updater->upgrade()
#7 {main}
Next exception 'Doctrine\\DBAL\\DBALException' with message 'An exception occurred while executing 'CREATE TABLE [oc_appconfig] ([appid] NVARCHAR(32) DEFAULT '' NOT NULL, [configkey] NVARCHAR(64) DEFAULT '' NOT NULL, [configvalue] VARCHAR(MAX) NULL, PRIMARY KEY ([appid], [configkey]))':
SQLSTATE[42S01]: [Microsoft][SQL Server Native Client 11.0][SQL Server]In der Datenbank ist bereits ein Objekt mit dem Namen 'oc_appconfig' vorhanden.' in C:\\inetpub\\owncloud\\3rdparty\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\DBALException.php:47
Stack trace:
#0 C:\\inetpub\\owncloud\\3rdparty\\doctrine\\dbal\\lib\\Doctrine\\DBAL\\Connection.php(744): Doctrine\\DBAL\\DBALException::driverExceptionDuringQuery(Object(PDOException), 'CREATE TABLE [o...')
#1 C:\\inetpub\\owncloud\\lib\\private\\db\\mdb2schemamanager.php(152): Doctrine\\DBAL\\Connection->query('CREATE TABLE [o...')
#2 C:\\inetpub\\owncloud\\lib\\private\\db\\mdb2schemamanager.php(91): OC\\DB\\MDB2SchemaManager->executeSchemaChange(Object(Doctrine\\DBAL\\Schema\\SchemaDiff))
#3 C:\\inetpub\\owncloud\\lib\\private\\db.php(376): OC\\DB\\MDB2SchemaManager->updateDbFromStructure('C:\/inetpub\/ownc...')
#4 C:\\inetpub\\owncloud\\lib\\private\\updater.php(106): OC_DB::updateDbFromStructure('C:\/inetpub\/ownc...')
#5 C:\\inetpub\\owncloud\\core\\ajax\\update.php(34): OC\\Updater->upgrade()
#6 {main})","level":4,"time":"2013-12-18T08:26:37+00:00"}
Debugging the issue, I found that the schema comparison fails because the current schema is read without quoting table names and the destination schema is created with quoting table names, identifiers etc.
Workaround: Editing mdb2schemareader.php and commenting all lines similar to
$name = $this->platform->quoteIdentifier($name);
resolved the issue.
@bantu @ringmaster
See #5639. Patch provided in #6138 that performs the fix that the OP describes causes issues with other databases (particularly those that don't use a table prefix where our table name is a reserved word, like "users"), and I believe may have been subsequently reverted for additional review.
The mentioned patch was merged, closing hence.