Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Patience and the right tools II – ways to handl...

Patience and the right tools II – ways to handle 
content model changes

stefan judis

June 28, 2018
Tweet

More Decks by stefan judis

Other Decks in Technology

Transcript

  1. Stefan Judis Frontend Developer, Occasional Teacher, Meetup Organizer ❤ Open

    Source, Performance and Accessibility ❤ @stefanjudis
  2. MIGRATION CLI CONTENT TYPE OPERATIONS Create a content type 01

    02 03 04 05 Delete a content type Edit a content type Create/edit/delete fields Change a field ID
  3. Transform an entry in place 01 02 Derive an entry

    from another MIGRATION CLI CONTENT TRANSFORMATIONS
  4. MIGRATION CLI ADVANTAGES Repeatable 01 02 03 04 Can be

    kept in VC Includes sanity checks Perfect for CI
  5. cdn.contentful.com/spaces/{space_id}/environments/{environment_id}/entries const contentful = require('contentful'); const client = contentful.createClient({ space:

    '<space_id>', environment: '<environment_id>', accessToken: '<content_delivery_api_key>' }); client.getEntries();
  6. COPIED Content types Entries Assets Locales UI-extensions Saved views SHARED

    Users & space memberships Roles & permissions API keys Web hooks
  7. 0_0_8.js module.exports = function runMigration(migration) { const post = migration.editContentType("post");

    post .createField("rating") .name("Rating") .type("Number") .required(false); return; };
  8. - run: name: Preparing environment for testing command: | .

    venv/bin/activate python scripts/migration_prep.py "CI_$CIRCLE_BRANCH" scripts/migrate.js $SPACE_ID "CI_$CIRCLE_BRANCH" $MANAGEMENT_API_KEY
  9. - run: name: Preparing environment for testing command: | .

    venv/bin/activate python scripts/migration_prep.py "CI_$CIRCLE_BRANCH" scripts/migrate.js $SPACE_ID "CI_$CIRCLE_BRANCH" $MANAGEMENT_API_KEY client = contentful_management.Client(MANGEMENT_API_KEY) environment = client.environments(SPACE_ID).create(TESTING_ENV, {"name": TESTING_ENV})
  10. - run: name: Preparing environment for testing command: | .

    venv/bin/activate python scripts/migration_prep.py "CI_$CIRCLE_BRANCH" scripts/migrate.js $SPACE_ID "CI_$CIRCLE_BRANCH" $MANAGEMENT_API_KEY const {default: runMigration} = require('contentful-migration/built/bin/cli'); await runMigration({ /* ... */ }); client = contentful_management.Client(MANGEMENT_API_KEY) environment = client.environments(SPACE_ID).create(TESTING_ENV, {"name": TESTING_ENV})