Giter VIP home page Giter VIP logo

migrations-boilerplate's Introduction

Kontent.ai CLI migrations examples

The Kontent.ai CLI boilerplate aims to help with your first migration code. We've provided sample migration scripts in the Migrations folder. These scripts are written in Javascript and Typescript to show you the basic operations.

If you are missing your use case, you might find answers in the Management API reference.

The Kontent.ai CLI tool supports only Javascript files, so if you write your migrations in Typescript or any other language you have to transpile your code before running.

Installation

npm install

Setup

Before you run your migrations, you need to store some information about the environment locally.

The environment is defined as a named pair of values. For example, "DEV" environment can be defined as a pair of a specific environment ID and Management API key. This named pair of values is stored within your local repository in a configuration file named .environments.json.

# Adds a 'DEV' environment reference.
kontent environment add --name DEV --environment-id "<YOUR_ENVIRONMENT_GUID>" --api-key "<YOUR_MANAGAMENT_API_KEY>"

Usage

If you've set up an environment using the method above, you can use the prepared scripts to run all migrations in the Migrations directory.

# Executes all migration scripts in the 'Migrations' folder to the 'DEV' environment reference within your Kontent project. 
npm run migrate:all

If you want to run a specific migration you can use also script defined in packages.json

# Executes a migration script named 'my_migration'.
npm run migrate "my_migration"

Tip: For more information about Kontent migrations, see the Kontent.ai CLI documentation.

Feedback & Contribution

Feedback & Contributions are welcomed. Feel free to take/start an issue & submit PR.

migrations-boilerplate's People

Contributors

ileshmistry avatar ivankiral avatar kontent-ai-bot avatar pokornyd avatar simply007 avatar winklertomas avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

migrations-boilerplate's Issues

Add examples for rollback

Motivation

CLI now supports rollback scripts, whose implementation should ensure that the changes introduced by run are reverted back to the previous state.

Proposed solution

Add examples of rollback scripts to boilerplate examples.

Consider ignoring environments.json in git

Motivation

When you start using the environment boilerplate and set up the environment API keys, it is pretty easy to leak the keys, because this file is not ignored by default.

Proposed solution

Ignore the .environments.json by default. And ensure Kontent CLI creates a .environments.json file by default, or ensure this i.e. as preinstall script.

Run a range/set of migration

It would be usefull to be able to run a set of migrations. Currently it is possible to sun just one migration, or all of them.

There might be a problem, how to run the range of migration in combination to have the status.json coherent. It might involve making some adjustments into kontent-cli.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.