Add posts, tags, tagging, to database. Create references to align with new DB model. Add image of mermaid template model.

This commit is contained in:
hannah.dagemark 2025-05-15 16:35:29 +02:00 committed by Hannah Dagemark
commit 8ee5dd9322
17 changed files with 154 additions and 2 deletions

View file

@ -0,0 +1,14 @@
class CreatePosts < ActiveRecord::Migration[8.0]
def change
create_table :posts do |t|
t.string :title
t.text :content
t.boolean :pinned
t.references :user, null: false, foreign_key: true
t.references :image, null: false, foreign_key: true
t.string :type
t.timestamps
end
end
end

View file

@ -0,0 +1,10 @@
class CreateTags < ActiveRecord::Migration[8.0]
def change
create_table :tags do |t|
t.string :title
t.string :color
t.timestamps
end
end
end

View file

@ -0,0 +1,10 @@
class CreateTaggings < ActiveRecord::Migration[8.0]
def change
create_table :taggings do |t|
t.references :tag, null: false, foreign_key: true
t.references :taggable, polymorphic: true, null: false
t.timestamps
end
end
end

35
db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_05_08_131043) do
ActiveRecord::Schema[8.0].define(version: 2025_05_15_135623) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@ -45,6 +45,36 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_08_131043) do
t.datetime "updated_at", null: false
end
create_table "posts", force: :cascade do |t|
t.string "title"
t.text "content"
t.boolean "pinned"
t.integer "user_id", null: false
t.integer "image_id", null: false
t.string "type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["image_id"], name: "index_posts_on_image_id"
t.index ["user_id"], name: "index_posts_on_user_id"
end
create_table "taggings", force: :cascade do |t|
t.integer "tag_id", null: false
t.string "taggable_type", null: false
t.integer "taggable_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["tag_id"], name: "index_taggings_on_tag_id"
t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable"
end
create_table "tags", force: :cascade do |t|
t.string "title"
t.string "color"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "name"
t.string "status"
@ -56,4 +86,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_08_131043) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "posts", "images"
add_foreign_key "posts", "users"
add_foreign_key "taggings", "tags"
end