Jump to:

23361 Posts in 18124 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » SS table names and case sensitivity

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 5784 Views
  • Willr
    Avatar
    Forum Moderator
    5483 Posts

    Re: SS table names and case sensitivity Link to this post

    Aleks - you shouldn't need to start from scratch. You can find several tools online to help with migrate between the 2 formats. I'll dig up the script that we used back in the day when half the developers had MS, half Unix.

  • aleks
    Avatar
    Community Member
    7 Posts

    Re: SS table names and case sensitivity Link to this post

    Willr, thanks for the help but I pretty much sorted it out now.

    Just thought it would be good to mention it again and maybe do something that will prevent other 'newcomers' running into this trap.

  • KlamathPort
    Avatar
    Community Member
    2 Posts

    Re: SS table names and case sensitivity Link to this post

    Hi Willr, This issue still exists. Anybody creating the database on a Windows box and deploying to Linux would suffer this problem...
    Did you have that script handy?

    Here's one I threw together using nekranox's list:

    <?php
    /**
    * If you installed SilverStripe under windows MySQL with the ignore_case feature enabled (as it is by default) then you probably need this.
    * It will help you rename all the tables in an SQL Dump back into case sensitivity
    *
    * Directions:
    * set $file to the sqldump.
    * Include this class from your _config.php
    * If it says "The follow tables aren't accounted for" and lists some tables, add the correct case version of them to the list below, and try again.
    *
    * If it succeeds, it will print the new SQLDump for you to reimport.
    *
    * More info:
    * http://silverstripe.org/general-questions/show/11285
    * http://cosminswiki.com/index.php/MySQL_case_insensitive_table_and_column_names
    *
    * @author Dean Rather <dean@deanrather.com>
    * @version 1.1
    * @date 2011-08-03
    */

    $file = file_get_contents('../mysqldump.sql');
    $defaultTables = "ArchiveWidget
    BlogEntry
    BlogEntry_Live
    Blogentry_Lersions
    BlogHolder
    BlogHolder_Live
    BlogHolder_Versions
    BlogTree
    BlogTree_Live
    BlogTree_Versions
    ContactPage
    ContactPage_Live
    ContactPage_Versions
    Email_BounceRecord
    ErrorPage
    ErrorPage_Live
    ErrorPage_Versions
    File
    Gallery
    Group
    Group_Members
    Group_Roles
    HomePage
    HomePage_Live
    HomePage_Versions
    LoginAttempt
    Member
    MemberPassword
    MageComment
    Panel
    Permission
    PermissionRole
    PermissionRoleCode
    Products
    ProductsPage
    ProductsPage_Live
    ProductsPage_Versions
    Products_Live
    Products_versions
    QueuedEmail
    RedirectorPage
    RedirectorPage_Live
    RedirectorPage_Versions
    RSSWidget
    SiteConfig
    SiteConfig_CreateTopLevelGroups
    SiteConfig_EditorGroups
    SiteConfig_ViewerGroups
    SiteTree
    SiteTree_EditorGroups
    SiteTree_ImageTracking
    SiteTree_LinkTracking
    SiteTree_Live
    SiteTree_versions
    SiteTree_ViewerGroups
    TagCloudWidget
    TrackBackPing
    VirtualPage
    VirtualPage_Live
    VirtualPage_versions
    Widget
    WidgetArea
    PageComment";

    $fixed = explode("\r\n", $defaultTables);
    $lower = explode("\r\n", strtolower($defaultTables));

    // What tables do I actually have
    $database = $databaseConfig['database'];
    $sql = "SHOW TABLES FROM `$database`";
    DB::connect($databaseConfig);
    $result = DB::query($sql);
    $actual = array();
    foreach($result as $row) {
    foreach($row as $table) {
    $actual[] = $table;
    }
    }

    // Which tables are not catered for in the default list
    $missing = '';
    foreach($actual as $actualTable) {
    if(array_search($actualTable, $lower)===false) $missing .= "<br />$actualTable";
    }
    if($missing) {
    exit("<b>The follow tables aren't accounted for:</b> $missing");
    }

    foreach($fixed as $word) {
    $file = str_replace(strtolower("`$word`"), "`$word`", $file);
    }

    exit("<pre>$file</pre>");

    http://dl.dropbox.com/u/1574931/fixTables.php

  • onion
    Avatar
    Community Member
    10 Posts

    Re: SS table names and case sensitivity Link to this post

    I also had this problem today and caused a massive issue. I have been adding content to my development site in Windows (using Xampp) but now when adding it to the server it doesn't work because of mismatched cases. It's caused a horrible headache in the final hour that I didn't need!

    Apparently this could all have been avoided by changing this option in xampp:
    lower_case_table_names=0

    But I didn't know until I'd added all my pages and content. Annoying!

    Anyway rant over. I managed to solve this by renaming all the tables to put the uppercase letters back in :-S

    5784 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.