{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/bake/issues/119","labels_url":"https://api.github.com/repos/cakephp/bake/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/bake/issues/119/comments","events_url":"https://api.github.com/repos/cakephp/bake/issues/119/events","html_url":"https://github.com/cakephp/bake/issues/119","id":87685592,"number":119,"title":"Support DB prefixes when baking code","user":{"login":"burzum","id":162789,"avatar_url":"https://avatars.githubusercontent.com/u/162789?v=3","gravatar_id":"","url":"https://api.github.com/users/burzum","html_url":"https://github.com/burzum","followers_url":"https://api.github.com/users/burzum/followers","following_url":"https://api.github.com/users/burzum/following{/other_user}","gists_url":"https://api.github.com/users/burzum/gists{/gist_id}","starred_url":"https://api.github.com/users/burzum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/burzum/subscriptions","organizations_url":"https://api.github.com/users/burzum/orgs","repos_url":"https://api.github.com/users/burzum/repos","events_url":"https://api.github.com/users/burzum/events{/privacy}","received_events_url":"https://api.github.com/users/burzum/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/bake/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/bake/milestones/14","html_url":"https://github.com/cakephp/bake/milestones/1.2","labels_url":"https://api.github.com/repos/cakephp/bake/milestones/14/labels","id":1314886,"number":14,"title":"1.2","description":"New larger features and enhancements.","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":2,"state":"open","created_at":"2015-09-20T01:55:09Z","updated_at":"2015-12-30T14:56:34Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2015-06-12T10:36:08Z","updated_at":"2015-12-30T15:41:34Z","closed_at":null,"body":"**Use Case:**\r\n\r\nI'm in the situation that I finally need to apply https://github.com/cakephp/cakephp/issues/4118 because of a legacy app. When I want to bake my code for the old DB that uses a prefix, how can I tell bake and cake to use that prefix? I don't want to end up with everything in my app being prefix by `ho_`?\r\n\r\n**Proposed solution:**\r\n\r\nThe way I see it for this situation is this: Let's modify bake to support `--db-prefix`. `--db-prefix` will make bake aware to use the prefix, for example my `ho_`. But bake won't use it in the generated code then. Bake will create the table() call with the prefix then but ignore it everywhere else. Sounds fine?"},"comment":{"url":"https://api.github.com/repos/cakephp/bake/issues/comments/168021369","html_url":"https://github.com/cakephp/bake/issues/119#issuecomment-168021369","issue_url":"https://api.github.com/repos/cakephp/bake/issues/119","id":168021369,"user":{"login":"ionas","id":106845,"avatar_url":"https://avatars.githubusercontent.com/u/106845?v=3","gravatar_id":"","url":"https://api.github.com/users/ionas","html_url":"https://github.com/ionas","followers_url":"https://api.github.com/users/ionas/followers","following_url":"https://api.github.com/users/ionas/following{/other_user}","gists_url":"https://api.github.com/users/ionas/gists{/gist_id}","starred_url":"https://api.github.com/users/ionas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ionas/subscriptions","organizations_url":"https://api.github.com/users/ionas/orgs","repos_url":"https://api.github.com/users/ionas/repos","events_url":"https://api.github.com/users/ionas/events{/privacy}","received_events_url":"https://api.github.com/users/ionas/received_events","type":"User","site_admin":false},"created_at":"2015-12-30T15:41:34Z","updated_at":"2015-12-30T15:41:34Z","body":"* This is an extended example of prepareing a legacy database schema for cakephp conventions utilized by bake.\r\n* This whole file is NOT mandatory but a way to teach bake to respect non-conventional table names, primary keys and foreign key names.\r\n* RFC: Could all these cases be treated by real-sql foreign keys? Do all our supported adapters support real-sql foreign keys (sqlite?)\r\n* XML is not a must, but it is very clear what's going on. JSON could also be used / XML allows validation prior to parsing, which is good here!\r\n```xml\r\n<tables-bake-configuration>\r\n    <table>\r\n        <name>wp_authors</name>\r\n        <alias>users</name>\r\n        <primaryKey>\r\n            <name>uid</name>\r\n            <alias>id</alias>\r\n        </primaryKey>\r\n    </table>\r\n    <table>\r\n        <name>wp_posts</name>\r\n        <alias>posts</name>\r\n        <primaryKey>\r\n            <name>pid</name>\r\n            <alias>id</alias>\r\n        </primaryKey>\r\n        <foreignKey>\r\n            <name>authors_id</name>\r\n            <alias>user_id</alias>\r\n        </foreignKey>\r\n    </table>\r\n    <table>\r\n        <name>wp_comments</name>\r\n        <alias>comments</name>\r\n        <primaryKey>\r\n            <name>cid</name>\r\n            <alias>id</alias>\r\n        </primaryKey>\r\n        <foreignKey>\r\n            <name>authors_id</name>\r\n            <alias>user_id</alias>\r\n        </foreignKey>\r\n        <foreignKey>\r\n            <name>pid</name>\r\n            <alias>post_id</alias>\r\n        </foreignKey>\r\n    </table>\r\n    <table>\r\n        <name>wp_posts_ratings</name>\r\n        <alias>post_ratings</name>\r\n        <!-- Composite Primary Key Example -->\r\n        <primaryKey>\r\n            <name>pid</name>\r\n            <alias>post_id</alias>\r\n        </primaryKey>\r\n        <primaryKey>\r\n            <name>authors_id</name>\r\n            <alias>user_id</alias>\r\n        </primaryKey>\r\n        <foreignKey>\r\n            <name>pid</name>\r\n            <alias>post_id</alias>\r\n        </foreignKey>\r\n        <foreignKey>\r\n            <name>authors_id</name>\r\n            <alias>user_id</alias>\r\n        </foreignKey>\r\n    </table>\r\n</tables-bake-configuration>"}}