Column |
Type |
Options |
name |
string |
null: false |
- has_many :members
- has_many :users, through: :members
- has_many :messages
Column |
Type |
Options |
name |
string |
null: false |
mail |
text |
null: false |
- has_many :members
- has_many :groups, through: :members
- has_many :messages
Column |
Type |
Options |
user_id |
references |
foreign_key: true |
group_id |
references |
foreign_key: true |
- belongs_to :group
- belongs_to :user
Column |
Type |
Options |
message |
text |
|
image |
text |
|
user_id |
references |
foreign_key: true |
group_id |
references |
foreign_key: true |
- belongs_to :user
- belongs_to :group
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
で データベースにアクセスできる