Made messages more thread-like (replies, editing, etc.)

This commit is contained in:
MrYummy
2017-06-15 14:27:42 +02:00
parent 80026caebc
commit 9b50ec652c
21 changed files with 380 additions and 21 deletions

View File

@@ -1,10 +1,11 @@
class CreateMessages < ActiveRecord::Migration
def change
create_table :messages do |t|
t.text :message
t.references :user_sender
t.references :user_target
t.references :user_editor
t.references :user_hidden
t.datetime :created_at
end
end

View File

@@ -0,0 +1,13 @@
class CreateMessagereplies < ActiveRecord::Migration
def change
create_table :messagereplies do |t|
t.text :text
t.references :user_author
t.references :user_editor
t.references :message
t.timestamps null: true
end
end
end

View File

@@ -0,0 +1,5 @@
class AddUserEditorToMessages < ActiveRecord::Migration
def change
add_reference :messages, :user_editor
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170525184355) do
ActiveRecord::Schema.define(version: 20170613144233) do
create_table "blogposts", force: :cascade do |t|
t.string "title", limit: 191
@@ -76,11 +76,24 @@ ActiveRecord::Schema.define(version: 20170525184355) do
t.string "color", limit: 191
end
create_table "messagereplies", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "user_author_id", limit: 4
t.integer "user_editor_id", limit: 4
t.integer "message_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "messages", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "user_sender_id", limit: 4
t.integer "user_target_id", limit: 4
t.integer "user_hidden_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
t.string "subject", limit: 191
t.integer "user_editor_id", limit: 4
end
create_table "register_tokens", force: :cascade do |t|

View File

@@ -61,5 +61,6 @@ Message.create!(
user_sender_id: 2,
user_target_id: 2,
text: "This is a very long message that I will be using to test a plentitude of things. :)",
created_at: Time.utc(0).to_datetime
created_at: Time.utc(0).to_datetime,
subject: "Hello there!"
)