Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 1.71 KB

README.md

File metadata and controls

63 lines (40 loc) · 1.71 KB

branching-rails-example

From this repo, you can learn:

  • How to connect to TiDB Serverless in ruby on rails.
  • How to use branching GitHub integration.

About this repo

This repo is a rails blog example. it includes:

The repo is based on the blog tutorial.

Connect to TiDB Serverless in ruby on rails

Make sure you have installed the ruby and rails environment.

  1. clone the code
git clone git@github.com:tidbcloud/branching-rails-example.git
cd branching-rails-example
  1. Install the dependencies
bundle install
  1. Fill in the following environment variable defined in config/database.yml. You can find the information in the TiDB Serverless console.
export TIDB_DATABASE=
export TIDB_USER=
export TIDB_HOST=
export TIDB_PASSWORD=
export TIDB_CERT_PATH=
  1. Migrate and seed
rake db:migrate
rake db:seed
  1. Run the server
rails server

Use branching GitHub integration

Assume that you have run the rails project on a TiDB Serverless. Next, you can use the Branching GitHub integration to connect the TiDB Serverless to this repo. Then a database branch will be created for every pull request to test the changes before merging the code to the master branch.

This repo has already connected to a TiDB Serverless. Check this pull request to see how we check the migration changes!