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

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

22725c2d3eb331146549bf0d5d3c050c?s=128

stefan judis

June 28, 2018
Tweet

Transcript

  1. Patience and the right tools @stefanjudis Ways to handle
 content

    model changes
  2. Stefan Judis Frontend Developer, Occasional Teacher, Meetup Organizer ❤ Open

    Source, Performance and Accessibility ❤ @stefanjudis
  3. NOBODY(!) GETS IT RIGHT THE FIRST TIME...

  4. 4 WAYS TO SURVIVE SHARE & REUSE ANALYSE EVOLVE

  5. 5 WAYS TO SURVIVE SHARE & REUSE ANALYSE EVOLVE

  6. github.com/contentful/contentful-migration

  7. github.com/contentful/contentful-migration PROGRAMMATIC CONTENT MODEL CHANGES

  8. 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
  9. Transform an entry in place 01 02 Derive an entry

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

    kept in VC Includes sanity checks Perfect for CI
  11. None
  12. speakerdeck.com/stefanjudis/patience-and-the-right-tools-ways-to-approach-content-modelling youtu.be/eX2FzlA-QnQ

  13. 13 How to DISCARD TEST PREVIEW a migration?

  14. Sandbox Environments

  15. None
  16. CREATE MULTIPLE VERSIONS OF A SPACE CHANGE/TEST THEM IN ISOLATION

  17. cdn.contentful.com/spaces/{space_id}/entries const contentful = require('contentful'); const client = contentful.createClient({ space:

    '<space_id>', accessToken: '<content_delivery_api_key>' }); client.getEntries();
  18. 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();
  19. COPIED Content types Entries Assets Locales UI-extensions Saved views SHARED

    Users & space memberships Roles & permissions API keys Web hooks
  20. youtu.be/7DE6PQ3tPyI

  21. 21 Common use cases LOCAL DEVELOPMENT STAGING/QA CONTINUOUS INTEGRATION

  22. 22 Common use cases LOCAL DEVELOPMENT STAGING/QA CONTINUOUS INTEGRATION

  23. None
  24. 24 Common use cases LOCAL DEVELOPMENT STAGING/QA CONTINUOUS INTEGRATION

  25. FEATURE SANDBOXES

  26. FEATURE SANDBOXES ENVIRONMENT SANDBOXES

  27. ENVIRONMENT SANDBOXES FEATURE SANDBOXES CI SANDBOXES

  28. www.contentful.com/r/knowledgebase/cms-as-code/ www.contentful.com/developers/docs/concepts/multiple-environments/

  29. www.contentful.com/r/knowledgebase/cms-as-code/ www.contentful.com/developers/docs/concepts/multiple-environments/ BUT HOW TO DO THIS?

  30. None
  31. migrations 0_0_4.js 0_0_5.js 0_0_6.js 0_0_7.js 0_0_8.js

  32. 0_0_8.js module.exports = function runMigration(migration) { const post = migration.editContentType("post");

    post .createField("rating") .name("Rating") .type("Number") .required(false); return; };
  33. - 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
  34. - 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})
  35. - 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})
  36. Keep code and content model in sync

  37. Demo

  38. Feedback? Ideas?

  39. Integrate your content model into your delivery pipeline

  40. Thanks. @stefanjudis Slides ctfl.io/ci-environments Example ctfl.io/ci-environments-example