npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aphro/migration-runtime-ts

v0.1.7

Published

Your DB is on the client's device and you pushed an udpated to your app that changes the DB schema! OMG! What DO!?

Downloads

53

Readme

Migration Runtime

Your DB is on the client's device and you pushed an udpated to your app that changes the DB schema! OMG! What DO!?

The migration library provides a set of tools to enable you to manage and migrate database versions.

Tools

  • Interact with db metadata (e.g., version, pull schemas)
  • Compare table schemas in app vs table schemas in db
  • Drop tables
  • Recreate tables
  • Calculate alter statements
  • Apply migrations

Some prior art from the days when websql was a thing:

  • https://github.com/nanodeath/JS-Migrator/blob/master/migrator.js
  • https://blog.maxaller.name/2010/03/html5-web-sql-database-intro-to-versioning-and-migrations/
  • https://gist.github.com/YannickGagnon/5320593

Ideas

Yolo Mode

  1. Drop mode
  2. Auto-alter mode

Drop mode just drops and re-creates the tables any time a delta is detected.

Auto-alter diffs the (1) running schema with the (2) persisted schema. Deltas are converted to alter table statements and run.

Versioned mode

Versioned mode works by having a version in the schema file.

Any time the version jumps the next codegen run will generate a migration script placeholder. This'll have generate alter statements within but also allow the author to insert their own logic. E.g., to map old columns to new.

Logging

We need to get data back about failed migrations from our clients. Is this opt-in? Do we create a package that can be included to gather error data and ship it back home?

CRDTs

We need to consider how we'll handle tables that are replicated p2p in the face of migrations.

  1. We could stop clients from participating in the network until they've upgraded to the version of the most up to date client...
  2. We could run migration scripts (the data transform not alter table parts) in-memory to move an old version write to a new one. This of course needs to be reversable too and... if fields are combined what happens to their clocks?

Probably go with (1) for the MVP. (1) still has clock and versioning issues though... similar to what (2) had but we cut the bi-directional problem.

  1. Counter
  2. LWW registers
  3. Sequence
  4. clock push
  5. Row level vs column level resolution

Prior art

https://github.com/groue/GRDB.swift/blob/master/README.md (see their migrations syntax and handling -- pretty nice)