Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: BENCH

on:
push:
branches: [master]
paths-ignore:
- 'docs/**'
- '*.md'
Expand Down Expand Up @@ -45,13 +46,16 @@ jobs:
run: npm ci --prefer-offline --no-audit

- name: Create db schema
run: DATABASE_URL="postgresql://postgres:changeme@localhost:5440/graphql-registry?schema=public" npx prisma db push --preview-feature
run: |
docker exec -t postgres createdb -U postgres graphql-registry
DATABASE_URL="postgresql://postgres:changeme@localhost:5440/graphql-registry?schema=public" npm run migrate

- name: Build app image
run: docker-compose up -d app

- name: Bench
run: |
sleep 5
docker-compose run k6 run /benchmark/composed-schema.js

- name: Clean services
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

on:
push:
branches: [master]
paths-ignore:
- 'docs/**'
- '*.md'
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ WORKDIR /usr/src/app

COPY package*.json ./

COPY prisma ./

RUN npm ci

COPY . .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ This activates authorization in the `/schema/push` endpoint. Only the client wit
```
docker-compose up postgres
# Create db schema
npx prisma db push --preview-feature
npm run migrate
npm run dev
npm run test
```
Expand Down
4 changes: 4 additions & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
client: 'pg',
connection: process.env.DATABASE_URL,
}
60 changes: 60 additions & 0 deletions migrations/20210504193054_initial_schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
*
* @param {import("knex").Knex} knex
* @returns
*/
exports.up = (knex) => {
return knex.schema
.createTable('graph', (table) => {
table.increments('id').primary().notNullable()

table.string('name').unique().notNullable()
table.boolean('isActive').notNullable().defaultTo(true)
table.timestamp('createdAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
table.timestamp('updatedAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
})
.createTable('service', (table) => {
table.increments('id').primary()

table.string('name')
table.boolean('isActive').notNullable().defaultTo(true)
table.timestamp('createdAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
table.timestamp('updatedAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())

table.integer('graphId').unsigned().references('id').inTable('graph').index()
})
.createTable('schema', (table) => {
table.increments('id').primary()

table.string('typeDefs')
table.boolean('isActive').notNullable().defaultTo(true)
table.timestamp('createdAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
table.timestamp('updatedAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
table.integer('graphId').unsigned().references('id').inTable('graph').index()

table.integer('serviceId').unsigned().references('id').inTable('service').index()
})
.createTable('schema_tag', (table) => {
table.increments('id').primary()

table.string('version')
table.boolean('isActive').notNullable().defaultTo(true)
table.timestamp('createdAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())
table.timestamp('updatedAt', { useTz: true }).notNullable().defaultTo(knex.fn.now())

table.integer('schemaId').unsigned().references('id').inTable('schema').index()
})
}

/**
*
* @param {import("knex").Knex} knex
* @returns
*/
exports.down = (knex) => {
return knex.schema
.raw('DROP TABLE graph CASCADE')
.raw('DROP TABLE schema CASCADE')
.raw('DROP TABLE schema_tag CASCADE')
.raw('DROP TABLE service CASCADE')
}
Loading