{"action":"created","comment":{"url":"https://api.github.com/repos/typeorm/typeorm/pulls/comments/240511297","pull_request_review_id":183555823,"id":240511297,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDUxMTI5Nw==","diff_hunk":"@@ -272,14 +272,13 @@ export class Connection {\n      * Runs all pending migrations.\n      * Can be used only after connection to the database is established.\n      */\n-    async runMigrations(options?: { transaction?: boolean }): Promise<Migration[]> {\n+    async runMigrations(options?: { transactionMode?: \"all\" | \"none\" | \"each\" }): Promise<Migration[]> {","path":"src/connection/Connection.ts","position":5,"original_position":5,"commit_id":"031635b30ebab14f374024e41057429f98690d9d","original_commit_id":"031635b30ebab14f374024e41057429f98690d9d","user":{"login":"pleerock","id":1753397,"node_id":"MDQ6VXNlcjE3NTMzOTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1753397?v=4","gravatar_id":"","url":"https://api.github.com/users/pleerock","html_url":"https://github.com/pleerock","followers_url":"https://api.github.com/users/pleerock/followers","following_url":"https://api.github.com/users/pleerock/following{/other_user}","gists_url":"https://api.github.com/users/pleerock/gists{/gist_id}","starred_url":"https://api.github.com/users/pleerock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pleerock/subscriptions","organizations_url":"https://api.github.com/users/pleerock/orgs","repos_url":"https://api.github.com/users/pleerock/repos","events_url":"https://api.github.com/users/pleerock/events{/privacy}","received_events_url":"https://api.github.com/users/pleerock/received_events","type":"User","site_admin":false},"body":"I think we can simplify it and just call it `transaction`","created_at":"2018-12-11T08:31:39Z","updated_at":"2018-12-11T08:31:39Z","html_url":"https://github.com/typeorm/typeorm/pull/3208#discussion_r240511297","pull_request_url":"https://api.github.com/repos/typeorm/typeorm/pulls/3208","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/comments/240511297"},"html":{"href":"https://github.com/typeorm/typeorm/pull/3208#discussion_r240511297"},"pull_request":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/3208"}}},"pull_request":{"url":"https://api.github.com/repos/typeorm/typeorm/pulls/3208","id":236667241,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2NjY3MjQx","html_url":"https://github.com/typeorm/typeorm/pull/3208","diff_url":"https://github.com/typeorm/typeorm/pull/3208.diff","patch_url":"https://github.com/typeorm/typeorm/pull/3208.patch","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/3208","number":3208,"state":"open","locked":false,"title":"[WIP] Add new mode to wrap each migration in transaction","user":{"login":"garbles","id":1139884,"node_id":"MDQ6VXNlcjExMzk4ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1139884?v=4","gravatar_id":"","url":"https://api.github.com/users/garbles","html_url":"https://github.com/garbles","followers_url":"https://api.github.com/users/garbles/followers","following_url":"https://api.github.com/users/garbles/following{/other_user}","gists_url":"https://api.github.com/users/garbles/gists{/gist_id}","starred_url":"https://api.github.com/users/garbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garbles/subscriptions","organizations_url":"https://api.github.com/users/garbles/orgs","repos_url":"https://api.github.com/users/garbles/repos","events_url":"https://api.github.com/users/garbles/events{/privacy}","received_events_url":"https://api.github.com/users/garbles/received_events","type":"User","site_admin":false},"body":"Addresses https://github.com/typeorm/typeorm/issues/2693\r\n\r\nCreates a new, backwards compatible mode for running migrations each in their own transaction. This behaviour is what I think most expect as default from an ORM, so running all migrations in a single transaction seems odd. Using a single transaction also does not allow you to do certain things (in Postgres at least) if you expect to be able to run all migrations at once.\r\n\r\nFor example, if you have the following two migrations, you can **never** run all of from scratch.\r\n\r\n```ts\r\nimport { MigrationInterface, QueryRunner } from \"typeorm\";\r\n\r\nexport class CreateUuidExtension1544044606093 implements MigrationInterface {\r\n  public up(queryRunner: QueryRunner): Promise<any> {\r\n    return queryRunner.query(`CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";`);\r\n  }\r\n\r\n  public down(queryRunner: QueryRunner): Promise<any> {\r\n    return queryRunner.query('DROP EXTENSION \"uuid-ossp\"');\r\n  }\r\n}\r\n```\r\n\r\n```ts\r\nimport { MigrationInterface, QueryRunner, Table } from \"typeorm\";\r\n\r\nexport class CreateUsers1543965157399 implements MigrationInterface {\r\n  public up(queryRunner: QueryRunner): Promise<any> {\r\n    return queryRunner.createTable(\r\n      new Table({\r\n        name: \"users\",\r\n        columns: [\r\n          { name: \"id\", type: \"uuid\", isPrimary: true, default: \"uuid_generate_v4()\" },\r\n        ]\r\n      })\r\n    );\r\n  }\r\n\r\n  public down(queryRunner: QueryRunner): Promise<any> {\r\n    return queryRunner.dropTable(\"users\");\r\n  }\r\n}\r\n```\r\n\r\nThe error is `function uuid_generate_v4() does not exist` because extensions cannot be referenced from the same transaction which they are created.\r\n\r\nChanges to the `-t` flag to accept: `all` (run all migrations in a single transaction), `each` (run each migration in a separate transaction), `none` (run all migrations without transactions) or `false` (same as none).\r\n\r\nTODO:\r\n- [x] Add new tests for 'each' mode\r\n- [ ] Clean up code","created_at":"2018-12-06T20:48:34Z","updated_at":"2018-12-11T08:31:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"027c05e284eb2efd190a212d837cd7b006b6e43e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/typeorm/typeorm/pulls/3208/commits","review_comments_url":"https://api.github.com/repos/typeorm/typeorm/pulls/3208/comments","review_comment_url":"https://api.github.com/repos/typeorm/typeorm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/3208/comments","statuses_url":"https://api.github.com/repos/typeorm/typeorm/statuses/031635b30ebab14f374024e41057429f98690d9d","head":{"label":"garbles:master","ref":"master","sha":"031635b30ebab14f374024e41057429f98690d9d","user":{"login":"garbles","id":1139884,"node_id":"MDQ6VXNlcjExMzk4ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1139884?v=4","gravatar_id":"","url":"https://api.github.com/users/garbles","html_url":"https://github.com/garbles","followers_url":"https://api.github.com/users/garbles/followers","following_url":"https://api.github.com/users/garbles/following{/other_user}","gists_url":"https://api.github.com/users/garbles/gists{/gist_id}","starred_url":"https://api.github.com/users/garbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garbles/subscriptions","organizations_url":"https://api.github.com/users/garbles/orgs","repos_url":"https://api.github.com/users/garbles/repos","events_url":"https://api.github.com/users/garbles/events{/privacy}","received_events_url":"https://api.github.com/users/garbles/received_events","type":"User","site_admin":false},"repo":{"id":160583282,"node_id":"MDEwOlJlcG9zaXRvcnkxNjA1ODMyODI=","name":"typeorm","full_name":"garbles/typeorm","private":false,"owner":{"login":"garbles","id":1139884,"node_id":"MDQ6VXNlcjExMzk4ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1139884?v=4","gravatar_id":"","url":"https://api.github.com/users/garbles","html_url":"https://github.com/garbles","followers_url":"https://api.github.com/users/garbles/followers","following_url":"https://api.github.com/users/garbles/following{/other_user}","gists_url":"https://api.github.com/users/garbles/gists{/gist_id}","starred_url":"https://api.github.com/users/garbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garbles/subscriptions","organizations_url":"https://api.github.com/users/garbles/orgs","repos_url":"https://api.github.com/users/garbles/repos","events_url":"https://api.github.com/users/garbles/events{/privacy}","received_events_url":"https://api.github.com/users/garbles/received_events","type":"User","site_admin":false},"html_url":"https://github.com/garbles/typeorm","description":"ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.","fork":true,"url":"https://api.github.com/repos/garbles/typeorm","forks_url":"https://api.github.com/repos/garbles/typeorm/forks","keys_url":"https://api.github.com/repos/garbles/typeorm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/garbles/typeorm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/garbles/typeorm/teams","hooks_url":"https://api.github.com/repos/garbles/typeorm/hooks","issue_events_url":"https://api.github.com/repos/garbles/typeorm/issues/events{/number}","events_url":"https://api.github.com/repos/garbles/typeorm/events","assignees_url":"https://api.github.com/repos/garbles/typeorm/assignees{/user}","branches_url":"https://api.github.com/repos/garbles/typeorm/branches{/branch}","tags_url":"https://api.github.com/repos/garbles/typeorm/tags","blobs_url":"https://api.github.com/repos/garbles/typeorm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/garbles/typeorm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/garbles/typeorm/git/refs{/sha}","trees_url":"https://api.github.com/repos/garbles/typeorm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/garbles/typeorm/statuses/{sha}","languages_url":"https://api.github.com/repos/garbles/typeorm/languages","stargazers_url":"https://api.github.com/repos/garbles/typeorm/stargazers","contributors_url":"https://api.github.com/repos/garbles/typeorm/contributors","subscribers_url":"https://api.github.com/repos/garbles/typeorm/subscribers","subscription_url":"https://api.github.com/repos/garbles/typeorm/subscription","commits_url":"https://api.github.com/repos/garbles/typeorm/commits{/sha}","git_commits_url":"https://api.github.com/repos/garbles/typeorm/git/commits{/sha}","comments_url":"https://api.github.com/repos/garbles/typeorm/comments{/number}","issue_comment_url":"https://api.github.com/repos/garbles/typeorm/issues/comments{/number}","contents_url":"https://api.github.com/repos/garbles/typeorm/contents/{+path}","compare_url":"https://api.github.com/repos/garbles/typeorm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/garbles/typeorm/merges","archive_url":"https://api.github.com/repos/garbles/typeorm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/garbles/typeorm/downloads","issues_url":"https://api.github.com/repos/garbles/typeorm/issues{/number}","pulls_url":"https://api.github.com/repos/garbles/typeorm/pulls{/number}","milestones_url":"https://api.github.com/repos/garbles/typeorm/milestones{/number}","notifications_url":"https://api.github.com/repos/garbles/typeorm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/garbles/typeorm/labels{/name}","releases_url":"https://api.github.com/repos/garbles/typeorm/releases{/id}","deployments_url":"https://api.github.com/repos/garbles/typeorm/deployments","created_at":"2018-12-05T21:52:42Z","updated_at":"2018-12-07T06:26:42Z","pushed_at":"2018-12-07T06:26:40Z","git_url":"git://github.com/garbles/typeorm.git","ssh_url":"git@github.com:garbles/typeorm.git","clone_url":"https://github.com/garbles/typeorm.git","svn_url":"https://github.com/garbles/typeorm","homepage":"http://typeorm.io","size":10730,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","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":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"typeorm:master","ref":"master","sha":"efb6353fdcdb0715596cc53db48fcf6633d8de7b","user":{"login":"typeorm","id":20165699,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMTY1Njk5","avatar_url":"https://avatars0.githubusercontent.com/u/20165699?v=4","gravatar_id":"","url":"https://api.github.com/users/typeorm","html_url":"https://github.com/typeorm","followers_url":"https://api.github.com/users/typeorm/followers","following_url":"https://api.github.com/users/typeorm/following{/other_user}","gists_url":"https://api.github.com/users/typeorm/gists{/gist_id}","starred_url":"https://api.github.com/users/typeorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typeorm/subscriptions","organizations_url":"https://api.github.com/users/typeorm/orgs","repos_url":"https://api.github.com/users/typeorm/repos","events_url":"https://api.github.com/users/typeorm/events{/privacy}","received_events_url":"https://api.github.com/users/typeorm/received_events","type":"Organization","site_admin":false},"repo":{"id":52773157,"node_id":"MDEwOlJlcG9zaXRvcnk1Mjc3MzE1Nw==","name":"typeorm","full_name":"typeorm/typeorm","private":false,"owner":{"login":"typeorm","id":20165699,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMTY1Njk5","avatar_url":"https://avatars0.githubusercontent.com/u/20165699?v=4","gravatar_id":"","url":"https://api.github.com/users/typeorm","html_url":"https://github.com/typeorm","followers_url":"https://api.github.com/users/typeorm/followers","following_url":"https://api.github.com/users/typeorm/following{/other_user}","gists_url":"https://api.github.com/users/typeorm/gists{/gist_id}","starred_url":"https://api.github.com/users/typeorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typeorm/subscriptions","organizations_url":"https://api.github.com/users/typeorm/orgs","repos_url":"https://api.github.com/users/typeorm/repos","events_url":"https://api.github.com/users/typeorm/events{/privacy}","received_events_url":"https://api.github.com/users/typeorm/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/typeorm/typeorm","description":"ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.","fork":false,"url":"https://api.github.com/repos/typeorm/typeorm","forks_url":"https://api.github.com/repos/typeorm/typeorm/forks","keys_url":"https://api.github.com/repos/typeorm/typeorm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/typeorm/typeorm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/typeorm/typeorm/teams","hooks_url":"https://api.github.com/repos/typeorm/typeorm/hooks","issue_events_url":"https://api.github.com/repos/typeorm/typeorm/issues/events{/number}","events_url":"https://api.github.com/repos/typeorm/typeorm/events","assignees_url":"https://api.github.com/repos/typeorm/typeorm/assignees{/user}","branches_url":"https://api.github.com/repos/typeorm/typeorm/branches{/branch}","tags_url":"https://api.github.com/repos/typeorm/typeorm/tags","blobs_url":"https://api.github.com/repos/typeorm/typeorm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/typeorm/typeorm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/typeorm/typeorm/git/refs{/sha}","trees_url":"https://api.github.com/repos/typeorm/typeorm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/typeorm/typeorm/statuses/{sha}","languages_url":"https://api.github.com/repos/typeorm/typeorm/languages","stargazers_url":"https://api.github.com/repos/typeorm/typeorm/stargazers","contributors_url":"https://api.github.com/repos/typeorm/typeorm/contributors","subscribers_url":"https://api.github.com/repos/typeorm/typeorm/subscribers","subscription_url":"https://api.github.com/repos/typeorm/typeorm/subscription","commits_url":"https://api.github.com/repos/typeorm/typeorm/commits{/sha}","git_commits_url":"https://api.github.com/repos/typeorm/typeorm/git/commits{/sha}","comments_url":"https://api.github.com/repos/typeorm/typeorm/comments{/number}","issue_comment_url":"https://api.github.com/repos/typeorm/typeorm/issues/comments{/number}","contents_url":"https://api.github.com/repos/typeorm/typeorm/contents/{+path}","compare_url":"https://api.github.com/repos/typeorm/typeorm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/typeorm/typeorm/merges","archive_url":"https://api.github.com/repos/typeorm/typeorm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/typeorm/typeorm/downloads","issues_url":"https://api.github.com/repos/typeorm/typeorm/issues{/number}","pulls_url":"https://api.github.com/repos/typeorm/typeorm/pulls{/number}","milestones_url":"https://api.github.com/repos/typeorm/typeorm/milestones{/number}","notifications_url":"https://api.github.com/repos/typeorm/typeorm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/typeorm/typeorm/labels{/name}","releases_url":"https://api.github.com/repos/typeorm/typeorm/releases{/id}","deployments_url":"https://api.github.com/repos/typeorm/typeorm/deployments","created_at":"2016-02-29T07:41:14Z","updated_at":"2018-12-11T08:21:32Z","pushed_at":"2018-12-10T07:28:40Z","git_url":"git://github.com/typeorm/typeorm.git","ssh_url":"git@github.com:typeorm/typeorm.git","clone_url":"https://github.com/typeorm/typeorm.git","svn_url":"https://github.com/typeorm/typeorm","homepage":"http://typeorm.io","size":10767,"stargazers_count":9635,"watchers_count":9635,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1105,"mirror_url":null,"archived":false,"open_issues_count":616,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1105,"open_issues":616,"watchers":9635,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/3208"},"html":{"href":"https://github.com/typeorm/typeorm/pull/3208"},"issue":{"href":"https://api.github.com/repos/typeorm/typeorm/issues/3208"},"comments":{"href":"https://api.github.com/repos/typeorm/typeorm/issues/3208/comments"},"review_comments":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/3208/comments"},"review_comment":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/typeorm/typeorm/pulls/3208/commits"},"statuses":{"href":"https://api.github.com/repos/typeorm/typeorm/statuses/031635b30ebab14f374024e41057429f98690d9d"}},"author_association":"NONE"}}
{"actor":{"display_login":"pleerock"}}