Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema versioning #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Schema versioning #183

wants to merge 1 commit into from

Conversation

brettz9
Copy link
Contributor

@brettz9 brettz9 commented May 3, 2016

There are a bunch of minor fixes or refactoring, testing, and doc improvements in this PR, but the main change in this PR is versioning of schemas. It is backwards-compatible, with the exception that now it will delete unused indexes by default (which I think should be fairly safe and fits in with the behavior that we auto-delete unused stores) and it will also destroy and rebuild stores if they are respecified with different options (e.g., a different keyPath). The README ought to be helpful in visualizing the new schemas (and schemaBuilder) formats.

  • Fix: Ensure return after rejection (in get and count);
  • Fix: Better type-checking for bad schema objects;
  • Fix: Polyfill newVersion for PhantomJS
  • API change (breaking)/Feature: Add clearUnusedIndexes option (defaults to true);
  • API change (breaking)/Feature: Destroy and rebuild stores or indexes if present with different options;
  • API addition: Support a schemas object keyed to version with values
    as schema objects. (Utilizes own IdbImport class, relying on own fork of idb-schema at least for now.);
    idb-schema callbacks will be passed db.js Server as second argument
  • API addition: Support a schemaBuilder callback which accepts an
    idb-schema object for incremental,
    versioned schema building and whose addCallback method will be
    passed an enhanced upgradeneeded event object with a Server object
    as a second argument for making db.js-style queries
    (e.g., to modify store content), albeit with certain limitations.
    Along with schemas, addresses issues Update/database migration #84/There is no way to test if the db.js is upgraded #109
  • API addition: Support a clearUnusedStores property to conditionally avoid deleting old stores.
  • API addition: Add db.del alias of db.delete
  • API addition: Add del() alias on Server for parity with idb-batch (likely to use or adapt for multiple change transactions);
  • Feature: Change schema (and allow for schemas) to differentiate between "mixed", "whole", "idb-schema", and "merge" types with schemaType option (defaulting to mixed for schema and whole for schemas, maintaining prior behavior in backward-compatible manner);
  • Docs: Update version and schema to take schemaBuilder into account
    (and document schemaBuilder).
  • Docs: Expand on key behavior examples;
  • Docs: Indicate that key is optional too
  • Docs: Add mention of missing limit on modify
  • Refactoring: Use const where possible;
  • Refactoring: Change variable placement including reordering static variables according to type (built-in alias, IDB, immutables, cache)
  • Refactoring: Avoid try-catch for brevity if will throw in sync body of Promise (but denote which lines may throw)
  • Refactoring: simplify transaction building
  • Refactoring: Add lang attribute for Atom linter-jade package;
  • Code comment: preventDefault not only for Firefox.
  • Code comment: Clarify how old connections may be closed
  • Testing: Schema building tests
  • Testing: Add tests for caching
  • Testing: Add test:local and phantom on package.json scripts
  • Testing: Fix server-handler test (expect specific error)
  • Testing: Fix test-worker to deal with multiple babel-polyfill instances
  • Testing: Remove redundant bad-args test
  • Testing: Unregister service worker

- Fix: Better type-checking for bad schema objects;
- Fix: Polyfill `newVersion` for PhantomJS
- API change (breaking)/Feature: Add `clearUnusedIndexes` option (defaults to `true`);
- API change (breaking)/Feature: Destroy and rebuild stores or indexes if present with different options;
- API addition: Support a `schemas` object keyed to version with values
as `schema` objects. (Utilizes own `IdbImport` class, relying on own fork of `idb-schema` at least for now.);
idb-schema callbacks will be passed db.js `Server` as second argument
- API addition: Support a `schemaBuilder` callback which accepts an
    [idb-schema](http://github.com/treojs/idb-schema) object for incremental,
    versioned schema building and whose `addCallback` method will be
    passed an enhanced `upgradeneeded` event object with a `Server` object
    as a second argument for making db.js-style queries
    (e.g., to modify store content), albeit with certain limitations.
    Along with `schemas`, addresses issues aaronpowell#84/aaronpowell#109
- API addition: Support a `clearUnusedStores` property to conditionally avoid deleting old stores.
- API addition: Add `db.del` alias of `db.delete`
- API addition: Add `del()` alias on `Server` for parity with `idb-batch` (likely to use or adapt for multiple change transactions);
- Feature: Change schema (and allow for `schemas`) to differentiate between "mixed", "whole", "idb-schema", and "merge" types with `schemaType` option (defaulting to `mixed` for `schema` and `whole` for `schemas`, maintaining prior behavior in backward-compatible manner);
- Docs: Update `version` and `schema` to take `schemaBuilder` into account
    (and document `schemaBuilder`).
- Docs: Expand on key behavior examples;
- Docs: Indicate that `key` is optional too
- Docs: Add mention of missing `limit` on `modify`
- Refactoring: Use `const` where possible;
- Refactoring: Change variable placement including reordering static variables according to type (built-in alias, IDB, immutables, cache)
- Refactoring: Avoid try-catch for brevity if will throw in sync body of Promise (but denote which lines may throw)
- Refactoring: simplify transaction building
- Refactoring: Add `lang` attribute for Atom linter-jade package;
- Code comment: `preventDefault` not only for Firefox.
- Code comment: Clarify how old connections may be closed
- Testing: Schema building tests
- Testing: Add tests for caching
- Testing: Add test:local and phantom on package.json scripts
- Testing: Fix server-handler test (expect specific error)
- Testing: Fix test-worker to deal with multiple babel-polyfill instances
- Testing: Remove redundant bad-args test
- Testing: Unregister service worker
@brettz9
Copy link
Contributor Author

brettz9 commented Oct 5, 2016

Any plans to review? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant