17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 5283 Views |
-
MySQL tables, Windows/Linux differences

24 May 2008 at 7:08pm
Hi all,
Just a quick question. I just pulled a site from work (windows environment) to my home machine (Ubuntu) and rebuilt. Can someone explain why in the Linux environment, the table names for classes were capitalised, but not in the Windows version?
For example, the relationship table "documentsgroup_mydocuments" in windows became "DocumentsGroup_MyDocuments" when built in linux.
Obviously, if you're developing on one platform this isn't a problem, but I'm switching between the two and it's a major hassle to go through and switch case depending on the machine.
Cheers
-
Re: MySQL tables, Windows/Linux differences

24 May 2008 at 7:28pm
This is because Silverstripe uses partially uppercase table names, but in Windows these are automatically converted to lowercase by MySQL.
See http://open.silverstripe.com/ticket/2476 -
Re: MySQL tables, Windows/Linux differences

30 May 2008 at 11:36pm
That's the reason why I wrote the following php-script. It translates a database
export-file from lowercase to camelcase and vice versa using an export-file
of the destination database as template for translation.
See attached php-script.
Run the scipt with '?help=1' for an explanation. -
Re: MySQL tables, Windows/Linux differences

24 July 2008 at 7:47pm
OK, just ran into the same problem again, but this time I took a few minutes to work on the /db/build function. This fixes the problem without the need for any extra scripts:
In sapphire/core/model/MySQLDatabase.php, edit the following function (I just added lines 3-6):public function checkAndRepairTable($tableName) {
if(!$this->runTableCheckCommand("CHECK TABLE `$tableName`")) {
if($this->runTableCheckCommand("CHECK TABLE `".strtolower($tableName)."`")) {
Database::alteration_message("Table $tableName: repaired","repaired");
return $this->renameTable(strtolower($tableName),$tableName);
}
Database::alteration_message("Table $tableName: repaired","repaired");
return $this->runTableCheckCommand("REPAIR TABLE `$tableName` USE_FRM");
} else {
return true;
}
}
Now, whenever the database is copied from a Windows to a Linux machine, just run /db/build and the tables are renamed properly. -
Re: MySQL tables, Windows/Linux differences

6 August 2008 at 6:18pm
Ok, I will try this next time when I need to move a DB.
Thanks. -
Re: MySQL tables, Windows/Linux differences

15 August 2008 at 2:28am Last edited: 15 August 2008 2:28am
This problem happened to me as well. I manually renamed the table names in my sql file that were affected and then added Blynx's code and it worked! Thanks Blynx.
| 5283 Views | ||
|
Page:
1
|
Go to Top |



