Skip to content

Commit

Permalink
chore: migrations (#964)
Browse files Browse the repository at this point in the history
* [GraphQL-Serverless-Contentful] Init the starter (#524)

* Init the project

* Added serverless

* Rename the starter

* move to serverless

* remove the hello handler

* static analysis testing

* removing the .build dir

* add .build to .gitignore

* .editorconfig

* added name and description package.json

* added prettier rules

* feat: Add Apollo and tests to the kit (#527)

* feat: Add testing to the kit

* add tsconfig.test

* Fix typescript jest

* fixed codegen

* fix: the test

* feat: adds healthcheck (#543)

* [GraphQL-Serverless-Contentful] Add Contentful to the project (#529)

* feat: Add testing to the kit

* add tsconfig.test

* Fix typescript jest

* fixed codegen

* fix: the test

* Add contentful to the project

* Add the post query mutation

* Add the update mutation

* added graphql.schema to git ignore

* deleted graphql.schema.json

* Add the comment model

* [graphql-pod-kit1] Create README For Graphql-Serverless Kit (#558)

* [GraphQL-Serverless-Contentful] Readme.md

* remove the showcase

* Update starters/graphql-serverless-contentful/README.md

Co-authored-by: Jessica Wilkins  <[email protected]>

Co-authored-by: Jessica Wilkins  <[email protected]>

* chore: adding serverless icons and updating config file

* updating graphql kit name

* locking down dependecies

* adding starter kit card to main site

* adding hasShowcase boolean to package.json

* updating starter kit name in package.json

* updating order for starter kit card

* updating starter kit name in serverless yaml file

* updating starter kits json file

* [GraphQL-Serverless-Contentful] Add seeding script to the starter kit (#585)

* Add seeding script

* fix: replace symbol for comma

Co-authored-by: Maarten Bicknese <[email protected]>

* chore: update all packages

Automatically update all packages to their latest versions by using
npm check updates.

Closes: #791
Relates to: #792

* chore: update to latest schema

* feat: use tabs over spaces

* chore: format all files and fix lint

* chore: convert all files to use tabs

Closes: #794

* fix: restore 2 spaces for yml

* fix: missing@graphql-tools/merge (#825)

* fix: missing@graphql-tools/merge

* chore: pin dep

* chore: verify pnpm (#816)

* [serverless-apollo-contentful] Change jest.config to be typescript#827 (#829)

* [serverless-apollo-contentful] Add missing .env file instructions (#820)

* init

* add screenshots

* docs: update content model docs

Co-authored-by: Maarten Bicknese <[email protected]>

* [serverless-apollo-contentful] Create Technology model (#861)

* feat: jest setup mocks and env

* chore: graphql-tools executor

* add tests

* chore: replicate post tests

* fix: typedefs

* fix: Post -> Comment

* fix: content

* update tests

* fix: tests for comments

* fix: format

* Update starters/graphql-serverless-contentful/src/schema/post/post.resolver.test.ts

Co-authored-by: Maarten Bicknese <[email protected]>

* chore: check if the have been called with

* feat: implement technology model

* chore: clean up old code

* docs: update readme for technology model

Closes: #851

* chore: remove left-over code

* fix: improve small issues

* fix: remove unused line

Co-authored-by: Ian Mungai <[email protected]>
Co-authored-by: kodejuice <[email protected]>

* [serverless-apollo-contentful] Update project structure and technology decisions explanation & Deployment in README  (#874)

* chore: update readme

* fix: remove screenshot

* [serverless-apollo-contentful] Add caching to kit (#897)

* add redis cache

* add redis instructions and docker container

* add docker commands and format

* move redis client

* use official redis image

* cache ttl

* Update starters/graphql-serverless-contentful/README.md

* add redis info to tech section in readme

* fix healthcheck - follow spec

* Update healthcheck.ts

* [serverless-apollo-contentful] Add database migration (#935)

* chore: add database migration  & add to readme

* fix: technology migration

* fix: prettier format

* [serverless-apollo-contentful] Add queueing to kit (#952)

* init

* setup handler and generator

* iamRoleStatements

* complete README

* Update starters/graphql-serverless-contentful/package.json

* typo

* remove params

* remove extra port

* undefined return type

* add env titles

* rename port

* add hint to job message

* remove caret

* [serverless-apollo-contentful] Clean up README.md (#958)

* chore: spelling mistakes

* chore: caching

* chore: migration & seeding

* chore: reorganize readme

* [graphql-serverless-contentful] Refractor getEnvironment (#939)

* refractor: getEnvironment

* chore: fix tests for contentful

* chore: contentful test

* fix: remove client

* chore: run prettier format

* fix: remove export client

* Update starters/graphql-serverless-contentful/src/schema/technology/technology.resolver.test.ts

Co-authored-by: Ihar Dziamidau <[email protected]>

* Update starters/graphql-serverless-contentful/src/schema/technology/technology.resolver.test.ts

Co-authored-by: Ihar Dziamidau <[email protected]>

* fix: contentful tests

* chore: fix async mockResolvedValue

* fix: unresolved dummyEnvironment

* chore: contentful test

---------

Co-authored-by: Ihar Dziamidau <[email protected]>

* chore: migrations

---------

Co-authored-by: Mark S. Shenouda <[email protected]>
Co-authored-by: William Hutt <[email protected]>
Co-authored-by: Jessica Wilkins  <[email protected]>
Co-authored-by: jdwilkin4 <[email protected]>
Co-authored-by: Maarten Bicknese <[email protected]>
Co-authored-by: Ihar Dziamidau <[email protected]>
Co-authored-by: Sochima Biereagu <[email protected]>
  • Loading branch information
8 people authored Feb 8, 2023
1 parent df06eda commit b48105b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 47 deletions.
37 changes: 36 additions & 1 deletion starters/graphql-serverless-contentful/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,48 @@ These are the defaults and should work seamlessly if you have Redis running alre
- `npm run lint` - Runs ESLint on the project.
- `npm run prettier` - Formats code for the entire project
- `npm run deploy` - Deploy your application on `AWS Lambda`
- `npm run db:migration` - Run database migrations
- `npm run db:seed` - Seed Database

### Migration

To manage our Contentful content types via code we implement migration scripts which are located in `scripts/migration`.

How to run migrations:

- First, install `contentful-cli`.

```sh
npm i -g contentful-cli
```

- Login to Contentful via `contentful-cli`.

```sh
contenful login
```

- Create a space using `contentful-cli`, if not created yet in Contentful web app.

```sh
contentful space create --name "ThisDot example"
```

- Set the newly-created space as the default space for all further CLI operations. This will present a list of all available spaces – choose the one we just created

```sh
contentful space use
```

- Migrations are located in `scripts/migrations/**`. Create a migration file here

- Run a migration using the following command

```sh
contentful space migration scripts/migrations/01-create-technology-contentType.js -y
```

[Learn more on migrations](https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/)

### Seeding

To pre-populate the data within contentful we implement seeding scripts which are located in `scripts/seed`.
Expand Down
3 changes: 1 addition & 2 deletions starters/graphql-serverless-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"format": "prettier --write \"**/*.{ts,js,json,md}\"",
"ts:check": "tsc --noEmit",
"codegen": "graphql-codegen --config codegen.ts",
"db:seed": "npm codegen && ts-node ./scripts/seed.ts",
"db:migration": "ts-node ./scripts/migration.ts"
"db:seed": "npm codegen && ts-node ./scripts/seed.ts"
},
"keywords": [
"serverless",
Expand Down
44 changes: 0 additions & 44 deletions starters/graphql-serverless-contentful/scripts/migration.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = function (migration) {
const technology = migration.createContentType('technology', {
name: 'Technology',
displayField: 'displayName',
description: 'Technology content type',
});

technology
.createField('displayName')
.name('Display Name')
.required(true)
.localized(true)
.type('Symbol');

technology
.createField('description')
.name('Description')
.required(false)
.localized(true)
.type('Symbol');

technology
.createField('url')
.name('URL')
.required(false)
.localized(true)
.validations([{ unique: true }])
.type('Symbol');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function (migration) {
const technology = migration.editContentType('technology');

technology.changeFieldControl('url', 'builtin', 'slugEditor');
};

0 comments on commit b48105b

Please sign in to comment.