{"action":"created","issue":{"url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/8","repository_url":"https://api.github.com/repos/phpthinktank/blast-orm","labels_url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/8/comments","events_url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/8/events","html_url":"https://github.com/phpthinktank/blast-orm/issues/8","id":132925746,"number":8,"title":"Seperate schema definitions from entity","user":{"login":"mbunge","id":395518,"avatar_url":"https://avatars.githubusercontent.com/u/395518?v=3","gravatar_id":"","url":"https://api.github.com/users/mbunge","html_url":"https://github.com/mbunge","followers_url":"https://api.github.com/users/mbunge/followers","following_url":"https://api.github.com/users/mbunge/following{/other_user}","gists_url":"https://api.github.com/users/mbunge/gists{/gist_id}","starred_url":"https://api.github.com/users/mbunge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbunge/subscriptions","organizations_url":"https://api.github.com/users/mbunge/orgs","repos_url":"https://api.github.com/users/mbunge/repos","events_url":"https://api.github.com/users/mbunge/events{/privacy}","received_events_url":"https://api.github.com/users/mbunge/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/phpthinktank/blast-orm/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"mbunge","id":395518,"avatar_url":"https://avatars.githubusercontent.com/u/395518?v=3","gravatar_id":"","url":"https://api.github.com/users/mbunge","html_url":"https://github.com/mbunge","followers_url":"https://api.github.com/users/mbunge/followers","following_url":"https://api.github.com/users/mbunge/following{/other_user}","gists_url":"https://api.github.com/users/mbunge/gists{/gist_id}","starred_url":"https://api.github.com/users/mbunge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbunge/subscriptions","organizations_url":"https://api.github.com/users/mbunge/orgs","repos_url":"https://api.github.com/users/mbunge/repos","events_url":"https://api.github.com/users/mbunge/events{/privacy}","received_events_url":"https://api.github.com/users/mbunge/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/phpthinktank/blast-orm/milestones/1","html_url":"https://github.com/phpthinktank/blast-orm/milestones/0.1.2","labels_url":"https://api.github.com/repos/phpthinktank/blast-orm/milestones/1/labels","id":1577206,"number":1,"title":"0.1.2","description":"","creator":{"login":"mbunge","id":395518,"avatar_url":"https://avatars.githubusercontent.com/u/395518?v=3","gravatar_id":"","url":"https://api.github.com/users/mbunge","html_url":"https://github.com/mbunge","followers_url":"https://api.github.com/users/mbunge/followers","following_url":"https://api.github.com/users/mbunge/following{/other_user}","gists_url":"https://api.github.com/users/mbunge/gists{/gist_id}","starred_url":"https://api.github.com/users/mbunge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbunge/subscriptions","organizations_url":"https://api.github.com/users/mbunge/orgs","repos_url":"https://api.github.com/users/mbunge/repos","events_url":"https://api.github.com/users/mbunge/events{/privacy}","received_events_url":"https://api.github.com/users/mbunge/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2016-02-11T09:25:34Z","updated_at":"2016-02-11T09:29:53Z","due_on":"2016-02-28T23:00:00Z","closed_at":null},"comments":1,"created_at":"2016-02-11T09:29:53Z","updated_at":"2016-02-11T18:59:46Z","closed_at":null,"body":"This:\r\n\r\n```php\r\nclass Post extends AbstractEntity\r\n{\r\n\r\n  /**\r\n   * Configure entity\r\n   */\r\n  public function configure()\r\n  {\r\n      $table = new Table('post');\r\n      $table->addColumn('id', Type::INTEGER)\r\n          ->setAutoincrement(true)\r\n          ->setLength(10);\r\n      $table->addColumn('title', Type::STRING);\r\n      $table->addColumn('content', Type::TEXT);\r\n      $table->addColumn('date', Type::DATETIME)\r\n          ->setDefault(new \\DateTime());\r\n      $table->setPrimaryKey(['id']);\r\n\r\n      //set entity table\r\n      $this->setTable($table);\r\n  }\r\n}\r\n```\r\n\r\nFeels wrong. Like not the syntax the class naming. First of all, maybe I am miss understanding something, and feel free to tell me.\r\nit should go: Migration -> Model -> Entity. as In we create a migration to create a new table, we create a model for that table and then we create an entity that extends the model.\r\nYou are extending an entity (abstract) and creating a table (??)\r\nThe way I understand it is: Migrations create the tables, Models know of the relation ships, table fields and do the \"find or create\" and the scopes (laravel) where as entities, least the way we use them, are classes that do the joins and the wheres and the get/set jazz (we use active record so no need for getters and setters)"},"comment":{"url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/comments/183010659","html_url":"https://github.com/phpthinktank/blast-orm/issues/8#issuecomment-183010659","issue_url":"https://api.github.com/repos/phpthinktank/blast-orm/issues/8","id":183010659,"user":{"login":"wolfy-j","id":796136,"avatar_url":"https://avatars.githubusercontent.com/u/796136?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfy-j","html_url":"https://github.com/wolfy-j","followers_url":"https://api.github.com/users/wolfy-j/followers","following_url":"https://api.github.com/users/wolfy-j/following{/other_user}","gists_url":"https://api.github.com/users/wolfy-j/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfy-j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfy-j/subscriptions","organizations_url":"https://api.github.com/users/wolfy-j/orgs","repos_url":"https://api.github.com/users/wolfy-j/repos","events_url":"https://api.github.com/users/wolfy-j/events{/privacy}","received_events_url":"https://api.github.com/users/wolfy-j/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T18:59:46Z","updated_at":"2016-02-11T18:59:46Z","body":"I'v been solving similar issue in my ORM and ended with following idea:\r\n1) Entity declares needed schema in internal DSL, in your case it can be something like:\r\n```php\r\n public static function declare()\r\n  {\r\n      $declaration= new Delcaration('post');\r\n      $declaration->requireColumn('id', Type::INTEGER)\r\n          ->setAutoincrement(true)\r\n          ->setLength(10);\r\n      $declaration->requireColumn('title', Type::STRING);\r\n      $declaration->requireColumn('content', Type::TEXT);\r\n      $declaration->requireColumn('date', Type::DATETIME)\r\n          ->setDefault(new \\DateTime());\r\n      $declaration->setPrimaryKey(['id']);\r\n\r\n      //set entity table\r\n      return $declaration;\r\n  }\r\n```\r\n2) ORM grabs declaration from known entities and generates set of needed migrations (based on DIFF)\r\n3) Migrations run - schema is synced\r\n\r\nOn practice you only need to read this declaration once and later cache it either in some file or via code generation."}}