summaryrefslogtreecommitdiffhomepage
path: root/packages/storage-sqlite/src/migrate.ts
blob: 43f418d6ad89d9c160269df1a57f2ed1974ce0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export interface Migration {
  readonly version: number;
  readonly name: string;
  readonly up: string;
}

export function computePending(
  appliedVersions: ReadonlySet<number>,
  migrations: readonly Migration[],
): readonly Migration[] {
  return migrations
    .filter((m) => !appliedVersions.has(m.version))
    .sort((a, b) => a.version - b.version);
}