Skip to content

コメント用のテーブルを作る#77

Merged
5t111111 merged 4 commits into
masterfrom
create-comments-table
Sep 6, 2016
Merged

コメント用のテーブルを作る#77
5t111111 merged 4 commits into
masterfrom
create-comments-table

Conversation

@yucao24hours

Copy link
Copy Markdown
Member

やったこと

Post に対する Comment を格納するためのテーブルを作るマイグレーションを作成しました。

実際にコメントを作成・表示するところは #64 でやるので、こちらを先にマージする必要があります。

対応する issue

connects to #35

class CreateComments < ActiveRecord::Migration[5.0]
def change
create_table :comments do |t|
t.integer :commented_by_id, null: false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

外部キーには外部キー制約とインデックスつけていいと思います


rename_column :comments, :user_id, :commented_by_id

add_foreign_key :comments, :users, column: 'commented_by_id'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@5t111111

5t111111 commented Sep 6, 2016

Copy link
Copy Markdown
Collaborator

LGTM

@5t111111 5t111111 merged commit f488f96 into master Sep 6, 2016
@5t111111 5t111111 deleted the create-comments-table branch September 6, 2016 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants