createMigrationIds
See source codeCreates a named set of migration IDs from version numbers and a sequence ID.
This utility function helps generate properly formatted migration IDs that follow
the required sequenceId/version
pattern. It takes a sequence ID and a record
of named versions, returning migration IDs that can be used in migration definitions.
See the migration guide for more info on how to use this API.
function createMigrationIds<
const ID extends string,
const Versions extends Record<string, number>,
>(
sequenceId: ID,
versions: Versions
): {
[K in keyof Versions]: `${ID}/${Versions[K]}`
}
Example
const migrationIds = createMigrationIds('com.myapp.book', {
addGenre: 1,
addPublisher: 2,
removeOldField: 3,
})
// Result: {
// addGenre: 'com.myapp.book/1',
// addPublisher: 'com.myapp.book/2',
// removeOldField: 'com.myapp.book/3'
// }
Parameters
Name | Description |
---|---|
|
The sequence identifier (e.g., 'com.myapp.book') |
|
Record mapping version names to numbers |
Returns
{
[K in keyof Versions]: `${ID}/${Versions[K]}`
}
Record mapping version names to properly formatted migration IDs
Prev
createComputedCacheNext
createMigrationSequence