Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
@hashicorp/dato-migration-gen
Advanced tools
This tool allows you to generate a Dato migration template & timestamped Dato migration file by providing a `migrationSpec`
This tool allows you to generate a Dato migration template & timestamped Dato migration file by providing a migrationSpec
It is a small Node-based CLI which wraps datocms-client
to accomplish the above.
dato-migration-gen create [--name=<Name for Dato migration>] [--path=<Path to migrationSpec file>]
The create
command will:
dato new migration
with the migration name
and generated template, thereby creating a timestamped Dato migration file.Our larger, more complex migrations need the following defined upfront in order to smooth the process:
This scripts generated by the CLI set up a workflow to more easily leverage Dato's CLI and JS API client (datocms-client
) for migrations.
migrationSpec
?A migrationSpec
is an object which you create in reference how the migration should proceed. This object should specify the following keys listed below to capture migration concepts in code and create a simpler workflow for migrations.
The goal is to create a workflow where developers should only need to create migrationSpec
s and assume the generated script will update records or migrate records successfully where possible, as well as produce a sensible log of errors if any occur during a given dato migrate ...
run.
targetModelApiKey
The current apiKey
of this existing, "target" model. This is the model of the records being migrated.
It's worth noting that this model's apiKey
(modelApiKey
) value is consistent across Dato environments when forked, unlike the model's id
.
destinationModelApiKey
The current apiKey
of the destination model. This is the model to which records will be migrated.
This apiKey
(modelApiKey
) value is consistent across Dato environments when forked, unlike the model's id
.
migrateAllRecords
An optional flag as to whether the script should migrate all records of the target model. This is helpful to use while verifying migration scripts. Set to true
when running the final migration to migrate ALL records.
dataMigrations
An array of objects which document the migration of a record's data. A dataMigration
object documents the following:
key | type | required | description |
---|---|---|---|
target | string | No | The field apiKey at which to get current data as it stands on the existing record, if not provided we assume usage of destination and transform will provide default values |
destination | string | No | The field apiKey as it exists on the destination model - this must be camelCased since we're creating records. If destination is not provided, scripts should assume target is sufficient, a one-to-one migration of the data as the field apiKey for said data is assumed to be the same |
transform | function | No | A function to run and transform current data to the desired format when targeting destination . This function will be passed the current value of the data at target on the record being migrated as well as the return value of your createContext function |
createContext
You may optionally specify a createContext
function for this model. This function can be async
and is passed the Dato client
as its only argument. The return value of createContext
will be passed as the second argument to every transform
function defined in dataMigrations
for this migrationSpec
FAQs
This tool allows you to generate a Dato migration template & timestamped Dato migration file by providing a `migrationSpec`
We found that @hashicorp/dato-migration-gen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 23 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.