Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 1.58 KB

README.md

File metadata and controls

69 lines (49 loc) · 1.58 KB

README

DB 設計

groups テーブル

Column Type Options
name string null: false

Association

  • has_many :members
  • has_many :users, through: :members
  • has_many :messages

users テーブル

Column Type Options
name string null: false
mail text null: false

Association

  • has_many :members
  • has_many :groups, through: :members
  • has_many :messages

members テーブル

Column Type Options
user_id references foreign_key: true
group_id references foreign_key: true

Association

  • belongs_to :group
  • belongs_to :user

messages テーブル

Column Type Options
message text
image text
user_id references foreign_key: true
group_id references foreign_key: true

Association

  • belongs_to :user
  • belongs_to :group

docker-compose

mkdir docker-data/mysql
でデータベースのディレクトリを作成しておく
docker-compose up
でインスタンスを立ち上げ
docker-compose exec rails bundle exec rake db:setup でデータベースを作成
http://localhost:3001/
でブラウザからアクセスできるようになる

ローカル環境に mysql クライアントがあれば、
mysql -u root -h 127.0.0.1 -P3307 -p
で データベースにアクセスできる