Skip to content

Latest commit

 

History

History
 
 

issue-creation

Create an Issue

Corresponding tutorial 🔗.

This is a sample app demonstrating how to use Bytebase API to create and rollout a database change.

Say your organization already has a DevOps platform and you want to integrate the database change into the development workflow. This app is for you.

The app is built with Next.js and TailwindCSS.

add issue

Prerequisites

  • Node >= 18

Getting Started

Step 1 - Start Bytebase

  1. Check out Self-host Bytebase via docker for more information.
  2. Create a service account. Choose the DBA role which is sufficient for this sample.

Service Account Create

  1. Record the service account key.

Service Account Create

Step 2 - Configure and run this app

  1. Clone this repository.

  2. Copy env-template.local to .env.local.

    cp env-template.local .env.local
  3. Update the env file with the created service account.

    • NEXT_PUBLIC_BB_HOST. The host where Bytebase is running. This usually is the external url.
    • NEXT_PUBLIC_BB_SERVICE_ACCOUNT. The service account created in step 1.
    • NEXT_PUBLIC_BB_SERVICE_KEY. The service key created in step 1.
  4. Run the following commands:

    pnpm i && pnpm dev

Open the host with your browser to see the running app.

API Usage

API Doc: https://github.com/bytebase/bytebase/blob/main/proto/gen/grpc-doc/v1/README.md

Fetch data

In src/app/page.tsx:

  • List all projects /v1/projects

  • List all databases /v1/instances/-/databases

Create an issue

In src/app/components/add-issue-form.tsx and src/app/api/xxxx/route.ts:

In order to create an issue, you need to create resources in the following order:

  1. Create a sheet
  2. Create a plan
  3. Create an issue
  4. Create a rollout

Fetch issue status

In src/app/components/add-issue-form.tsx:

  • Get issue by id /v1/projects/{project}/issues/{issue}

SQL Check

added 2024/8/15, which is not included in the tutorial