{"id":14991069,"url":"https://github.com/devlato/contentful-migrate-fork","last_synced_at":"2025-10-06T03:31:14.054Z","repository":{"id":57206503,"uuid":"275152304","full_name":"devlato/contentful-migrate-fork","owner":"devlato","description":"🐎 Schema migration tooling for Contentful, with state management","archived":false,"fork":true,"pushed_at":"2020-06-30T12:51:35.000Z","size":602,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T03:37:46.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.contentful.com/blog/2018/09/13/content-model-changes-scale-telus-cms-as-code/","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"deluan/contentful-migrate","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devlato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-26T12:36:23.000Z","updated_at":"2021-05-18T18:36:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/devlato/contentful-migrate-fork","commit_stats":null,"previous_names":["devlato/contentful-migrate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devlato/contentful-migrate-fork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlato%2Fcontentful-migrate-fork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlato%2Fcontentful-migrate-fork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlato%2Fcontentful-migrate-fork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlato%2Fcontentful-migrate-fork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devlato","download_url":"https://codeload.github.com/devlato/contentful-migrate-fork/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlato%2Fcontentful-migrate-fork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278555088,"owners_count":26006078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T14:21:24.831Z","updated_at":"2025-10-06T03:31:13.773Z","avatar_url":"https://github.com/devlato.png","language":"JavaScript","readme":"# Contentful Migrate Tool\n\n[![npm](https://img.shields.io/npm/v/contentful-migrate-fork.svg)](https://www.npmjs.com/package/contentful-migrate-fork)\n[![contentful-migration version](https://img.shields.io/npm/dependency-version/contentful-migrate-fork/contentful-migration)](https://www.npmjs.com/package/contentful-migration)\n[![Build Status](https://github.com/devlato/contentful-migrate-fork/workflows/CI/badge.svg)](https://github.com/devlato/contentful-migrate-fork/actions)\n[![Downloads](https://img.shields.io/npm/dm/contentful-migrate-fork)](https://www.npmjs.com/package/contentful-migrate-fork)\n\nManage your Contentful schema by creating incremental scripted changes. This project is based on the ideas exposed\nin [Contentful's CMS as Code article](https://www.contentful.com/r/knowledgebase/cms-as-code/)\n\nScripts are written using [Contentful's migration tool](https://github.com/contentful/contentful-migration) syntax. Ex:\n\n```javascript\nmodule.exports.description = \"Create Post model\";\n\nmodule.exports.up = migration =\u003e {\n  const post = migration\n    .createContentType(\"post\")\n    .name(\"Post\")\n    .displayField(\"title\")\n    .description(\"Post model\");\n\n  post\n    .createField(\"title\")\n    .name(\"Title\")\n    .type(\"Symbol\")\n    .required(true)\n    .localized(false);\n};\n\nmodule.exports.down = migration =\u003e {\n  migration.deleteContentType(\"post\");\n};\n```\n\nThis command line tool is designed to keep track of changes of content types individually. It keeps the\nscripts in a `migrations` folder in your project. This folder must contain one subfolder for each\ncontent type. Ex:\n\n```\nyour-project\n├── README.md\n├── migrations\n│   ├── banner\n│   │   └── 1513743198536-create-banner.js\n│   └── post\n│       ├── 1513695986378-create-post.js\n│       └── 1513716408272-add-date-field.js\n├── package.json\n.\n.\n.\n\n```\n\nFor more information on schema migrations technique and practice, see:\n\n- [Evolutionary Database Design](https://martinfowler.com/articles/evodb.html)\n- [Schema migration](https://en.wikipedia.org/wiki/Schema_migration)\n\n## Installation\n\n```sh\nnpm install -g contentful-migrate\n```\n\n## Usage\n\nMost of the available commands need a\n[personal access token](https://www.contentful.com/developers/docs/references/authentication/)\nfor accessing the CMA (Contentful Management API). You can pass the token using the `--access-token`\noption or setting an environment variable called `CONTENTFUL_MANAGEMENT_ACCESS_TOKEN`\n\n### init\n\nCreates the content type 'Migration' into the designated contentful space. This will be\nused to keep track of the current state of each managed content type.\n\n```\n  Usage: ctf-migrate init [options]\n\n  Options:\n\n    -t, --access-token [access-token]  CMA token, defaults to your environment variable CONTENTFUL_MANAGEMENT_ACCESS_TOKEN if empty\n    -s, --space-id [space-id]          space id to use\n    -e, --environment-id [env-id]      id of the environment within the space (default 'master')\n```\n\nIf the target space already has been init'd before, it will throw an error:\n\n`Content type with id \"migration\" already exists.`\n\n### bootstrap\n\nCreate your migration files for content models already in your space. It gives you the option to squash any previous migration state.\nNote: It will delete any existing migration scripts and create a consolidated one for each specified content type.\n\n```\n  Usage: ctf-migrate bootstrap [options]\n\n  Options:\n\n    -t, --access-token [access-token]  CMA token, defaults to your environment variable CONTENTFUL_MANAGEMENT_ACCESS_TOKEN if empty\n    -s, --space-id [space-id]          space id to use\n    -e, --environment-id [env-id]      id of the environment within the space (default 'master')\n    -c, --content-type [content-type]  one or more content type to bootstrap with choice to overwrite migration state\n    -a, --all                          apply bootstrap to all with choice to overwrite migration state\n```\n\nExample: executing the command `ctf-migrate bootstrap -c post -s \u003cspace-id\u003e` will create a file where the `up` command will generate the exact snapshot of the `Post` content model\n\n### create\n\nCreates an empty time stamped file in the content-type's migrations folder.\n\n```\n  Usage: ctf-migrate create \u003cname\u003e [options]\n\n  Options:\n\n    -c, --content-type \u003ccontent-type\u003e  content type name\n    -t, --migration-template \u003cmigration-template\u003e  migration file template path\n    -e, --extension \u003cextension\u003e  generated migration file extension\n```\n\nExample: executing the command `ctf-migrate create create-post-model -c post -t template.ts -e .ts` will create\na file named `./migrations/post/1513695986378-create-post.ts` (the timestamp will vary)\n\n### list\n\nLists all migrations for the given content-types, also indicating whether they were already\napplied and when.\n\n```\n  Usage: ctf-migrate list [options]\n\n  Options:\n\n    -t, --access-token [access-token]  CMA token, defaults to your environment variable CONTENTFUL_MANAGEMENT_ACCESS_TOKEN if empty\n    -s, --space-id [space-id]          space id to use\n    -e, --environment-id [env-id]      id of the environment within the space (default 'master')\n    -c, --content-type [content-type]  one or more content type names to list\n    -a, --all                          lists migrations for all content types\n```\n\nExample:\n\n```bash\n$ ctf-migrate list -s i2ztmmsocxul -c post banner\nListing post\n  [2017-12-19 22:12:58] 1513695986378-create-post.js : Create Post model\n  [pending] 1513716408272-add-title-field.js : Adds title field\nListing banner\n  [2018-01-08 15:01:45] 20180103165614-create-banner.js : Create Banner model\n  [2018-01-22 11:01:33] 20180111172942-add-subtitle-field.js: Add Subtitle field\n```\n\nFor the `post` model in this example, the first script (`create-post.js`) has already been applied but the\nsecond one (`add-title-field.js`) has not. For the `banner` model, all scripts have been applied.\n\n### up\n\nMigrates up to a specific version or all pending scripts if a filename is not informed. This will apply pending scripts for\nthe specified content-type into the specified space.\n\n```\n  Usage: ctf-migrate up [filename] [options]\n\n  Options:\n\n    -t, --access-token [access-token]  CMA token, defaults to your environment variable CONTENTFUL_MANAGEMENT_ACCESS_TOKEN if empty\n    -s, --space-id [space-id]          space id to use\n    -e, --environment-id [env-id]      id of the environment within the space (default 'master')\n    -c, --content-type [content-type]  one or more content type names to process\n    -a, --all                          processes migrations for all content types\n    -d, --dry-run                      only shows the plan, don't write anything to contentful. defaults to false\n```\n\n### down\n\n\u003e **ATTENTION**: As noted in the [CMS as Code article](https://www.contentful.com/r/knowledgebase/cms-as-code/#how-to-get-started),\n\"in real-world situations there is often no real way to down migrate content without resorting to backups\". Even though\nwe agree with that assertion, we still think there is value in having a `down` function to make it easier to develop\nand debug the `up` migration scripts (when you're working on a dev/test space), as it makes it easy to revert your\nchanges and try again, without resorting to any manual intervention.\\*\n\nMigrates down to a specific version or just the last one if filename is not informed. This will roll back applied scripts\nfor the specified content-type from the specified space.\n\n```\n  Usage: ctf-migrate down [filename] [options]\n\n  Options:\n\n    -t, --access-token [access-token]  CMA token, defaults to your environment variable CONTENTFUL_MANAGEMENT_ACCESS_TOKEN if empty\n    -s, --space-id [space-id]          space id to use\n    -e, --environment-id [env-id]      id of the environment within the space (default 'master')\n    -c, --content-type [content-type]  content type name\n    -d, --dry-run                      only shows the plan, don't write anything to contentful. defaults to false\n```\n\n## Writing Migrations\n\nFor more information on how to write migrations, see\n[Contentful migrations documentation](https://github.com/contentful/contentful-migration#documentation--references)\n\nThis tool is based on [node-migrate](https://github.com/tj/node-migrate). For more\ninformation on how to run migrations, see [Running migrations](https://github.com/tj/node-migrate#running-migrations)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlato%2Fcontentful-migrate-fork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlato%2Fcontentful-migrate-fork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlato%2Fcontentful-migrate-fork/lists"}