Add references between projects and todos
This commit is contained in:
5
db/migrate/20251027123148_add_project_id_to_todos.rb
Normal file
5
db/migrate/20251027123148_add_project_id_to_todos.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddProjectIdToTodos < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_reference :todos, :project, null: false, foreign_key: true
|
||||
end
|
||||
end
|
||||
6
db/schema.rb
generated
6
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_10_27_122702) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_10_27_123148) do
|
||||
create_table "projects", force: :cascade do |t|
|
||||
t.boolean "active", default: true, null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -24,6 +24,10 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_27_122702) do
|
||||
t.text "description"
|
||||
t.string "name"
|
||||
t.integer "priority", default: 1, null: false
|
||||
t.integer "project_id", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["project_id"], name: "index_todos_on_project_id"
|
||||
end
|
||||
|
||||
add_foreign_key "todos", "projects"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user