-
Notifications
You must be signed in to change notification settings - Fork 2
/
10-migration-to-create-initial-models.patch
117 lines (107 loc) · 3.58 KB
/
10-migration-to-create-initial-models.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
migration-to-create-initial-models
From: Bryan Larsen <[email protected]>
Now watch how Hobo can create a single migration for all of these:
$ ./script/generate hobo_migration
Fire up the app. It's not a polished UI of course, but we do actually have a working application. Make sure you are logged in as an administrator (e.g. the user who signed up first), and spend a few minutes populating the app with projects, stories and tasks.
With some more very simple changes, and without even touching the views, we can get surprisingly close to a decent UI.
---
...20091201020837_hobo_migration_initial_models.rb | 43 ++++++++++++++++++++
db/schema.rb | 38 +++++++++++++++++-
2 files changed, 80 insertions(+), 1 deletions(-)
create mode 100644 db/migrate/20091201020837_hobo_migration_initial_models.rb
diff --git a/db/migrate/20091201020837_hobo_migration_initial_models.rb b/db/migrate/20091201020837_hobo_migration_initial_models.rb
new file mode 100644
index 0000000..f7f95ac
--- /dev/null
+++ b/db/migrate/20091201020837_hobo_migration_initial_models.rb
@@ -0,0 +1,43 @@
+class HoboMigrationInitialModels < ActiveRecord::Migration
+ def self.up
+ create_table :task_assignments do |t|
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.integer :user_id
+ t.integer :task_id
+ end
+ add_index :task_assignments, [:user_id]
+ add_index :task_assignments, [:task_id]
+
+ create_table :projects do |t|
+ t.string :name
+ t.datetime :created_at
+ t.datetime :updated_at
+ end
+
+ create_table :tasks do |t|
+ t.string :description
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.integer :story_id
+ end
+ add_index :tasks, [:story_id]
+
+ create_table :stories do |t|
+ t.string :title
+ t.text :body
+ t.string :status
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.integer :project_id
+ end
+ add_index :stories, [:project_id]
+ end
+
+ def self.down
+ drop_table :task_assignments
+ drop_table :projects
+ drop_table :tasks
+ drop_table :stories
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 10ba9ae..32cb2cf 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,43 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20091201020248) do
+ActiveRecord::Schema.define(:version => 20091201020837) do
+
+ create_table "projects", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "stories", :force => true do |t|
+ t.string "title"
+ t.text "body"
+ t.string "status"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "project_id"
+ end
+
+ add_index "stories", ["project_id"], :name => "index_stories_on_project_id"
+
+ create_table "task_assignments", :force => true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "user_id"
+ t.integer "task_id"
+ end
+
+ add_index "task_assignments", ["task_id"], :name => "index_task_assignments_on_task_id"
+ add_index "task_assignments", ["user_id"], :name => "index_task_assignments_on_user_id"
+
+ create_table "tasks", :force => true do |t|
+ t.string "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "story_id"
+ end
+
+ add_index "tasks", ["story_id"], :name => "index_tasks_on_story_id"
create_table "users", :force => true do |t|
t.string "crypted_password", :limit => 40