{"action":"reopened","number":200,"pull_request":{"url":"https://api.github.com/repos/sdispater/orator/pulls/200","id":155806374,"html_url":"https://github.com/sdispater/orator/pull/200","diff_url":"https://github.com/sdispater/orator/pull/200.diff","patch_url":"https://github.com/sdispater/orator/pull/200.patch","issue_url":"https://api.github.com/repos/sdispater/orator/issues/200","number":200,"state":"open","locked":false,"title":"Add initialization function","user":{"login":"finetuned89","id":12174852,"avatar_url":"https://avatars3.githubusercontent.com/u/12174852?v=4","gravatar_id":"","url":"https://api.github.com/users/finetuned89","html_url":"https://github.com/finetuned89","followers_url":"https://api.github.com/users/finetuned89/followers","following_url":"https://api.github.com/users/finetuned89/following{/other_user}","gists_url":"https://api.github.com/users/finetuned89/gists{/gist_id}","starred_url":"https://api.github.com/users/finetuned89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finetuned89/subscriptions","organizations_url":"https://api.github.com/users/finetuned89/orgs","repos_url":"https://api.github.com/users/finetuned89/repos","events_url":"https://api.github.com/users/finetuned89/events{/privacy}","received_events_url":"https://api.github.com/users/finetuned89/received_events","type":"User","site_admin":false},"body":"If you use Orator in your applications, a common scenario is that you wish to create the database connection on startup and to run all migrations before starting the application. Previously, one would have to do something like:\r\n\r\n```\r\nfrom orator import Model, DatabaseManager\r\nfrom orator.migrations import Migrator, DatabaseMigrationRepository\r\nimport yaml\r\n\r\nwith open(\"orator.yml\") as file:\r\n        config = yaml.load(file)\r\n\r\n# Create connection\r\ndb = DatabaseManager(config['databases'])\r\nModel.set_connection_resolver(db)\r\n\r\n# Check for migrations\r\nrepository = DatabaseMigrationRepository(db, 'migrations')\r\nmigrator = Migrator(repository, db)\r\nif not migrator.repository_exists():\r\n    repository.create_repository()\r\n\r\nmigrations_dir = os.path.append(os.path.dirname(os.path.abspath(__file__)), \"migrations\")\r\nmigrator.run(migrations_dir)\r\n\r\n```\r\n\r\nWith this new convenience function, this is reduced to:\r\n\r\n```\r\nimport orator\r\norator.initialize()\r\n```\r\n\r\nOptionally, you can provide the location for the config file, the migrations dir, and whether or not you want to run the migrations:\r\n\r\n```\r\nimport orator\r\n\r\nconfig_file = \"config/orator.yml\"\r\nmigrations_dir =\"my_migrations\"\r\n\r\norator.initialize(config_file=\"config/orator.yml\", migrations_dir=\"my_migrations\")\r\n```\r\n\r\nOr, if you don't want to run the migrations:\r\n\r\n```\r\nimport orator\r\norator.initialize(run_migrations=False)\r\n```\r\n\r\nThe defaults values for these parameters are the same that are used by the Orator CLI.","created_at":"2017-12-01T08:24:21Z","updated_at":"2017-12-18T21:16:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d7cbc1ee59db19a2bce830de29b80fa97982730","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sdispater/orator/pulls/200/commits","review_comments_url":"https://api.github.com/repos/sdispater/orator/pulls/200/comments","review_comment_url":"https://api.github.com/repos/sdispater/orator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sdispater/orator/issues/200/comments","statuses_url":"https://api.github.com/repos/sdispater/orator/statuses/a97f8b1379acb61588d35643ca551e6ee41a62f8","head":{"label":"finetuned89:add-initialize-function","ref":"add-initialize-function","sha":"a97f8b1379acb61588d35643ca551e6ee41a62f8","user":{"login":"finetuned89","id":12174852,"avatar_url":"https://avatars3.githubusercontent.com/u/12174852?v=4","gravatar_id":"","url":"https://api.github.com/users/finetuned89","html_url":"https://github.com/finetuned89","followers_url":"https://api.github.com/users/finetuned89/followers","following_url":"https://api.github.com/users/finetuned89/following{/other_user}","gists_url":"https://api.github.com/users/finetuned89/gists{/gist_id}","starred_url":"https://api.github.com/users/finetuned89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finetuned89/subscriptions","organizations_url":"https://api.github.com/users/finetuned89/orgs","repos_url":"https://api.github.com/users/finetuned89/repos","events_url":"https://api.github.com/users/finetuned89/events{/privacy}","received_events_url":"https://api.github.com/users/finetuned89/received_events","type":"User","site_admin":false},"repo":{"id":95782223,"name":"orator","full_name":"finetuned89/orator","owner":{"login":"finetuned89","id":12174852,"avatar_url":"https://avatars3.githubusercontent.com/u/12174852?v=4","gravatar_id":"","url":"https://api.github.com/users/finetuned89","html_url":"https://github.com/finetuned89","followers_url":"https://api.github.com/users/finetuned89/followers","following_url":"https://api.github.com/users/finetuned89/following{/other_user}","gists_url":"https://api.github.com/users/finetuned89/gists{/gist_id}","starred_url":"https://api.github.com/users/finetuned89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finetuned89/subscriptions","organizations_url":"https://api.github.com/users/finetuned89/orgs","repos_url":"https://api.github.com/users/finetuned89/repos","events_url":"https://api.github.com/users/finetuned89/events{/privacy}","received_events_url":"https://api.github.com/users/finetuned89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/finetuned89/orator","description":"The Orator ORM provides a simple yet beautiful ActiveRecord implementation.","fork":true,"url":"https://api.github.com/repos/finetuned89/orator","forks_url":"https://api.github.com/repos/finetuned89/orator/forks","keys_url":"https://api.github.com/repos/finetuned89/orator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finetuned89/orator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finetuned89/orator/teams","hooks_url":"https://api.github.com/repos/finetuned89/orator/hooks","issue_events_url":"https://api.github.com/repos/finetuned89/orator/issues/events{/number}","events_url":"https://api.github.com/repos/finetuned89/orator/events","assignees_url":"https://api.github.com/repos/finetuned89/orator/assignees{/user}","branches_url":"https://api.github.com/repos/finetuned89/orator/branches{/branch}","tags_url":"https://api.github.com/repos/finetuned89/orator/tags","blobs_url":"https://api.github.com/repos/finetuned89/orator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finetuned89/orator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finetuned89/orator/git/refs{/sha}","trees_url":"https://api.github.com/repos/finetuned89/orator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finetuned89/orator/statuses/{sha}","languages_url":"https://api.github.com/repos/finetuned89/orator/languages","stargazers_url":"https://api.github.com/repos/finetuned89/orator/stargazers","contributors_url":"https://api.github.com/repos/finetuned89/orator/contributors","subscribers_url":"https://api.github.com/repos/finetuned89/orator/subscribers","subscription_url":"https://api.github.com/repos/finetuned89/orator/subscription","commits_url":"https://api.github.com/repos/finetuned89/orator/commits{/sha}","git_commits_url":"https://api.github.com/repos/finetuned89/orator/git/commits{/sha}","comments_url":"https://api.github.com/repos/finetuned89/orator/comments{/number}","issue_comment_url":"https://api.github.com/repos/finetuned89/orator/issues/comments{/number}","contents_url":"https://api.github.com/repos/finetuned89/orator/contents/{+path}","compare_url":"https://api.github.com/repos/finetuned89/orator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finetuned89/orator/merges","archive_url":"https://api.github.com/repos/finetuned89/orator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finetuned89/orator/downloads","issues_url":"https://api.github.com/repos/finetuned89/orator/issues{/number}","pulls_url":"https://api.github.com/repos/finetuned89/orator/pulls{/number}","milestones_url":"https://api.github.com/repos/finetuned89/orator/milestones{/number}","notifications_url":"https://api.github.com/repos/finetuned89/orator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finetuned89/orator/labels{/name}","releases_url":"https://api.github.com/repos/finetuned89/orator/releases{/id}","deployments_url":"https://api.github.com/repos/finetuned89/orator/deployments","created_at":"2017-06-29T13:46:50Z","updated_at":"2017-06-29T13:46:52Z","pushed_at":"2017-12-03T10:45:13Z","git_url":"git://github.com/finetuned89/orator.git","ssh_url":"git@github.com:finetuned89/orator.git","clone_url":"https://github.com/finetuned89/orator.git","svn_url":"https://github.com/finetuned89/orator","homepage":"https://orator-orm.com","size":943,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"0.9"}},"base":{"label":"sdispater:0.9","ref":"0.9","sha":"586cf6b69f9b69c257b75c7efa0e053b36eece96","user":{"login":"sdispater","id":555648,"avatar_url":"https://avatars1.githubusercontent.com/u/555648?v=4","gravatar_id":"","url":"https://api.github.com/users/sdispater","html_url":"https://github.com/sdispater","followers_url":"https://api.github.com/users/sdispater/followers","following_url":"https://api.github.com/users/sdispater/following{/other_user}","gists_url":"https://api.github.com/users/sdispater/gists{/gist_id}","starred_url":"https://api.github.com/users/sdispater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdispater/subscriptions","organizations_url":"https://api.github.com/users/sdispater/orgs","repos_url":"https://api.github.com/users/sdispater/repos","events_url":"https://api.github.com/users/sdispater/events{/privacy}","received_events_url":"https://api.github.com/users/sdispater/received_events","type":"User","site_admin":false},"repo":{"id":36186238,"name":"orator","full_name":"sdispater/orator","owner":{"login":"sdispater","id":555648,"avatar_url":"https://avatars1.githubusercontent.com/u/555648?v=4","gravatar_id":"","url":"https://api.github.com/users/sdispater","html_url":"https://github.com/sdispater","followers_url":"https://api.github.com/users/sdispater/followers","following_url":"https://api.github.com/users/sdispater/following{/other_user}","gists_url":"https://api.github.com/users/sdispater/gists{/gist_id}","starred_url":"https://api.github.com/users/sdispater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdispater/subscriptions","organizations_url":"https://api.github.com/users/sdispater/orgs","repos_url":"https://api.github.com/users/sdispater/repos","events_url":"https://api.github.com/users/sdispater/events{/privacy}","received_events_url":"https://api.github.com/users/sdispater/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sdispater/orator","description":"The Orator ORM provides a simple yet beautiful ActiveRecord implementation.","fork":false,"url":"https://api.github.com/repos/sdispater/orator","forks_url":"https://api.github.com/repos/sdispater/orator/forks","keys_url":"https://api.github.com/repos/sdispater/orator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sdispater/orator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sdispater/orator/teams","hooks_url":"https://api.github.com/repos/sdispater/orator/hooks","issue_events_url":"https://api.github.com/repos/sdispater/orator/issues/events{/number}","events_url":"https://api.github.com/repos/sdispater/orator/events","assignees_url":"https://api.github.com/repos/sdispater/orator/assignees{/user}","branches_url":"https://api.github.com/repos/sdispater/orator/branches{/branch}","tags_url":"https://api.github.com/repos/sdispater/orator/tags","blobs_url":"https://api.github.com/repos/sdispater/orator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sdispater/orator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sdispater/orator/git/refs{/sha}","trees_url":"https://api.github.com/repos/sdispater/orator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sdispater/orator/statuses/{sha}","languages_url":"https://api.github.com/repos/sdispater/orator/languages","stargazers_url":"https://api.github.com/repos/sdispater/orator/stargazers","contributors_url":"https://api.github.com/repos/sdispater/orator/contributors","subscribers_url":"https://api.github.com/repos/sdispater/orator/subscribers","subscription_url":"https://api.github.com/repos/sdispater/orator/subscription","commits_url":"https://api.github.com/repos/sdispater/orator/commits{/sha}","git_commits_url":"https://api.github.com/repos/sdispater/orator/git/commits{/sha}","comments_url":"https://api.github.com/repos/sdispater/orator/comments{/number}","issue_comment_url":"https://api.github.com/repos/sdispater/orator/issues/comments{/number}","contents_url":"https://api.github.com/repos/sdispater/orator/contents/{+path}","compare_url":"https://api.github.com/repos/sdispater/orator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sdispater/orator/merges","archive_url":"https://api.github.com/repos/sdispater/orator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sdispater/orator/downloads","issues_url":"https://api.github.com/repos/sdispater/orator/issues{/number}","pulls_url":"https://api.github.com/repos/sdispater/orator/pulls{/number}","milestones_url":"https://api.github.com/repos/sdispater/orator/milestones{/number}","notifications_url":"https://api.github.com/repos/sdispater/orator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sdispater/orator/labels{/name}","releases_url":"https://api.github.com/repos/sdispater/orator/releases{/id}","deployments_url":"https://api.github.com/repos/sdispater/orator/deployments","created_at":"2015-05-24T18:23:25Z","updated_at":"2017-12-18T19:11:02Z","pushed_at":"2017-12-10T22:09:28Z","git_url":"git://github.com/sdispater/orator.git","ssh_url":"git@github.com:sdispater/orator.git","clone_url":"https://github.com/sdispater/orator.git","svn_url":"https://github.com/sdispater/orator","homepage":"https://orator-orm.com","size":934,"stargazers_count":560,"watchers_count":560,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":61,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":61,"open_issues":59,"watchers":560,"default_branch":"0.9"}},"_links":{"self":{"href":"https://api.github.com/repos/sdispater/orator/pulls/200"},"html":{"href":"https://github.com/sdispater/orator/pull/200"},"issue":{"href":"https://api.github.com/repos/sdispater/orator/issues/200"},"comments":{"href":"https://api.github.com/repos/sdispater/orator/issues/200/comments"},"review_comments":{"href":"https://api.github.com/repos/sdispater/orator/pulls/200/comments"},"review_comment":{"href":"https://api.github.com/repos/sdispater/orator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sdispater/orator/pulls/200/commits"},"statuses":{"href":"https://api.github.com/repos/sdispater/orator/statuses/a97f8b1379acb61588d35643ca551e6ee41a62f8"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":1,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":20,"deletions":0,"changed_files":2}}
{"actor":{"display_login":"finetuned89"}}