{"action":"created","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5779","repository_url":"https://api.github.com/repos/silverstripe/silverstripe-framework","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5779/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5779/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5779/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5779","id":164233592,"number":5779,"title":"Fix table case sensitivity on Windows","user":{"login":"SilbinaryWolf","id":3859574,"avatar_url":"https://avatars.githubusercontent.com/u/3859574?v=3","gravatar_id":"","url":"https://api.github.com/users/SilbinaryWolf","html_url":"https://github.com/SilbinaryWolf","followers_url":"https://api.github.com/users/SilbinaryWolf/followers","following_url":"https://api.github.com/users/SilbinaryWolf/following{/other_user}","gists_url":"https://api.github.com/users/SilbinaryWolf/gists{/gist_id}","starred_url":"https://api.github.com/users/SilbinaryWolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilbinaryWolf/subscriptions","organizations_url":"https://api.github.com/users/SilbinaryWolf/orgs","repos_url":"https://api.github.com/users/SilbinaryWolf/repos","events_url":"https://api.github.com/users/SilbinaryWolf/events{/privacy}","received_events_url":"https://api.github.com/users/SilbinaryWolf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-07T05:40:10Z","updated_at":"2016-07-07T23:31:52Z","closed_at":null,"body":"Recently hit an issue where I'm developing on Windows alongside another Windows developer who had broken tables but was doing mostly frontend/data-entry work.\r\n\r\nMight be nice to add a ?force_rename param to /dev/build or something to fix this when using 'lower_case_table_names=2' with Windows. (Doing \"ALTER TABLE sitetree_live RENAME SiteTree_Live\" has no effect as it can't tell the difference)\r\n\r\n```\r\npublic function checkAndRepairTable($tableName) {\r\n\t\t// Flag to ensure we only send the warning about PDO + native mode once\r\n\t\tstatic $pdo_warning_sent = false;\r\n\r\n\t\t// If running PDO and not in emulated mode, check table will fail\r\n\t\tif($this->database->getConnector() instanceof PDOConnector && !PDOConnector::is_emulate_prepare()) {\r\n\t\t\tif (!$pdo_warning_sent) {\r\n\t\t\t\t$this->alterationMessage('CHECK TABLE command disabled for PDO in native mode', 'notice');\r\n\t\t\t\t$pdo_warning_sent = true;\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t// CODE HERE\r\n\t\t$this->renameTable(strtolower($tableName), $tableName.'_renameplease');\r\n\t\t$this->renameTable($tableName.'_renameplease', $tableName);\r\n\t\t// CODE HERE\r\n\r\n\t\t// Perform check\r\n\t\tif (!$this->runTableCheckCommand(\"CHECK TABLE \\\"$tableName\\\"\")) {\r\n\t\t\tif ($this->runTableCheckCommand(\"CHECK TABLE \\\"\" . strtolower($tableName) . \"\\\"\")) {\r\n\t\t\t\t$this->alterationMessage(\r\n\t\t\t\t\t\"Table $tableName: renamed from lowercase\",\r\n\t\t\t\t\t\"repaired\"\r\n\t\t\t\t);\r\n\t\t\t\treturn $this->renameTable(strtolower($tableName), $tableName);\r\n\t\t\t}\r\n\r\n\t\t\t$this->alterationMessage(\r\n\t\t\t\t\"Table $tableName: repaired\",\r\n\t\t\t\t\"repaired\"\r\n\t\t\t);\r\n\t\t\treturn $this->runTableCheckCommand(\"REPAIR TABLE \\\"$tableName\\\" USE_FRM\");\r\n\t\t} else {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n```"},"comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments/231237678","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5779#issuecomment-231237678","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5779","id":231237678,"user":{"login":"SilbinaryWolf","id":3859574,"avatar_url":"https://avatars.githubusercontent.com/u/3859574?v=3","gravatar_id":"","url":"https://api.github.com/users/SilbinaryWolf","html_url":"https://github.com/SilbinaryWolf","followers_url":"https://api.github.com/users/SilbinaryWolf/followers","following_url":"https://api.github.com/users/SilbinaryWolf/following{/other_user}","gists_url":"https://api.github.com/users/SilbinaryWolf/gists{/gist_id}","starred_url":"https://api.github.com/users/SilbinaryWolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilbinaryWolf/subscriptions","organizations_url":"https://api.github.com/users/SilbinaryWolf/orgs","repos_url":"https://api.github.com/users/SilbinaryWolf/repos","events_url":"https://api.github.com/users/SilbinaryWolf/events{/privacy}","received_events_url":"https://api.github.com/users/SilbinaryWolf/received_events","type":"User","site_admin":false},"created_at":"2016-07-07T23:31:52Z","updated_at":"2016-07-07T23:31:52Z","body":"Well the checkAndRepair stuff works on -Linux- machines and fixes the tables, but on Windows it sees \"sitetree_live\" and \"SiteTree_Live\" as the same value, so it doesn't rename them."}}
{"actor":{"display_login":"SilbinaryWolf"}}