Skip to content

Commit 1087047

Browse files
authored
Merge pull request #1 from adclleva/tasklists
created the tasklisk and associations
2 parents 81bbc80 + 1a20cf6 commit 1087047

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

app/models/task.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class Task < ApplicationRecord
2+
belongs_to :tasklist
23
end

app/models/tasklist.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Tasklist < ApplicationRecord
2+
has_many :tasks
3+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CreateTasklists < ActiveRecord::Migration[6.0]
2+
def change
3+
create_table :tasklists do |t|
4+
t.string :title
5+
t.string :description
6+
7+
t.timestamps
8+
end
9+
end
10+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddTasklistIdToTasks < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :tasks, :tasklist_id, :integer
4+
end
5+
end

db/schema.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,26 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2019_10_30_214810) do
13+
ActiveRecord::Schema.define(version: 2019_10_31_034318) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
1717

18+
create_table "tasklists", force: :cascade do |t|
19+
t.string "title"
20+
t.string "description"
21+
t.datetime "created_at", precision: 6, null: false
22+
t.datetime "updated_at", precision: 6, null: false
23+
end
24+
1825
create_table "tasks", force: :cascade do |t|
1926
t.string "title"
2027
t.string "description"
2128
t.datetime "created_at", precision: 6, null: false
2229
t.datetime "updated_at", precision: 6, null: false
2330
t.boolean "is_done", default: false
2431
t.datetime "due_date"
32+
t.integer "tasklist_id"
2533
end
2634

2735
end

0 commit comments

Comments
 (0)