Draft: Spike JH using independent database
What does this MR do and why?
Related issue: https://jihulab.com/gitlab-cn/gitlab/-/issues/2883
Use independent database for JH.
Spiked and implemented these functions:
- JH can use a separate postgresql database
- support such as `db:migrate:jh`, `db:rollback:jh` rake tasks now, `railt -T` will show all commands
- generated migration/schema files is placed into `jh/db/{migrate, schema_migrations}` folder
- JH models connect JH database successfully
- rails handle multiple models association with joins across multiple database
- JH tests run successfully
How to set up and validate locally
-
create
jh/db/migrate
andjh/db/schema_migrations
folders -
copy `jh/config/database.yml.example` contents into `config/database.yml`, modify it to fit your local development env
-
run `bundle exec rails db:create:jh` to create JH database
-
run `bundle exec rails db:migrate:jh` to perform 2 demo migrations, it should create `jh_cats` and `jh_balls` tables
-
run `bundle exec rails c` enter rails console, then can try these commands:
# model connect JH database JH::Cat.count JH::Cat.create! name: 'Ruby' # model associations with join across multiple database a = Project.last a.cats.count a.cats.create! name: 'Ruby' a.cats b = a.group b.cats a.cats.first.balls.create! name: 'Macbook Air' a.cats.first.balls a.balls
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
由 xfyuan 编辑于