Mailspring/script
Ben Gotow a14a5212ac feat(transactions): Explicit (and faster) database transactions
Summary:
Until now, we've been hiding transactions beneath the surface. When you call persistModel, you're implicitly creating a transaction.
You could explicitly create them with `atomically`..., but there were several critical problems that are fixed in this diff:

- Calling persistModel / unpersistModel within a transaction could cause the DatabaseStore to trigger. This could result in other parts of the app making queries /during/
  the transaction, potentially before the COMMIT occurred and saved the changes. The new, explicit inTransaction syntax holds all changes until after COMMIT and then triggers.

- Calling atomically and then calling persistModel inside that resulted in us having to check whether a transaction was present and was gross.

- Many parts of the code ran extensive logic inside a promise chained within `atomically`:

  BAD:

```
  DatabaseStore.atomically =>
   DatabaseStore.persistModel(draft) =>
     GoMakeANetworkRequestThatReturnsAPromise
```

OVERWHELMINGLY BETTER:

```
  DatabaseStore.inTransaction (t) =>
     t.persistModel(draft)
  .then =>
    GoMakeANetworkRequestThatReturnsAPromise
```

Having explicit transactions also puts us on equal footing with Sequelize and other ORMs. Note that you /have/ to call DatabaseStore.inTransaction (t) =>. There is no other way to access the methods that let you alter the database. :-)

Other changes:
- This diff removes Message.labels and the Message-Labels table. We weren't using Message-level labels anywhere, and the table could grow very large.
- This diff changes the page size during initial sync from 250 => 200 in an effort to make transactions a bit faster.

Test Plan: Run tests!

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D2353
2015-12-17 11:46:05 -08:00
..
utils test(contenteditable): add in contenteditable list specs 2015-12-02 13:41:47 -08:00
bootstrap feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
bootstrap.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
build fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
build.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
cibuild fix(build): bail if script/bootstrap fails and enhance test output 2015-11-23 14:34:18 -05:00
cibuild.ps1 feat(ci): add Travis and AppVeyor ci support 2015-12-07 12:48:26 -05:00
clean refactor(code): change atom to nylas in clean script 2015-10-07 21:34:07 -04:00
clean.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
copy-folder.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
create-shortcut.cmd fix(sqlite): Connect to sqlite directly rather than sending queries over IPC (twice...) 2015-07-30 18:09:20 -07:00
docs fix(build): bail if script/bootstrap fails and enhance test output 2015-11-23 14:34:18 -05:00
grunt fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
grunt.cmd fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
mkdeb Install package repo for autoupdates in Debian packages. 2015-10-04 19:38:16 -07:00
mkrpm refactor(n1): change launch script to N1.sh 2015-10-02 11:58:38 -07:00
rpmbuild fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
set-version ci(mac): Rename the app Nylas N1 on the Mac 2015-10-20 18:36:39 -07:00
test fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00