MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeMigration

Function makeMigration

packages/platform/browser/src/IndexedDbDatabase.ts:308–332  ·  view source on GitHub ↗
(options: {
  readonly previous:
    | IndexedDbSchema<FromVersion, ToVersion, Error>
    | IndexedDbSchema<never, FromVersion, Error>
  readonly fromVersion: FromVersion
  readonly version: ToVersion
  readonly migrate: (
    fromQuery: Transaction<FromVersion>,
    toQuery: Transaction<ToVersion>
  ) => Effect.Effect<void, Error>
})

Source from the content-addressed store, hash-verified

306}
307
308const makeMigration = <
309 FromVersion extends IndexedDbVersion.AnyWithProps,
310 ToVersion extends IndexedDbVersion.AnyWithProps,
311 Error
312>(options: {
313 readonly previous:
314 | IndexedDbSchema<FromVersion, ToVersion, Error>
315 | IndexedDbSchema<never, FromVersion, Error>
316 readonly fromVersion: FromVersion
317 readonly version: ToVersion
318 readonly migrate: (
319 fromQuery: Transaction<FromVersion>,
320 toQuery: Transaction<ToVersion>
321 ) => Effect.Effect<void, Error>
322}): IndexedDbSchema<FromVersion, ToVersion, Error> => {
323 // oxlint-disable-next-line typescript/no-extraneous-class
324 function Migration() {}
325 Object.setPrototypeOf(Migration, SchemaProto)
326 ;(Migration as any).previous = options.previous
327 ;(Migration as any).fromVersion = options.fromVersion
328 ;(Migration as any).version = options.version
329 ;(Migration as any).migrate = options.migrate
330
331 return Migration as any
332}
333
334const layer = <DatabaseName extends string>(
335 databaseName: DatabaseName,

Callers 1

addFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected