-
Notifications
You must be signed in to change notification settings - Fork 2
/
06-initial-migration.patch
92 lines (80 loc) · 3.27 KB
/
06-initial-migration.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
initial-migration
From: Bryan Larsen <[email protected]>
OUTPUT_FILE: agility.markdown
## Run the app
With Hobo, you get a bare-bones application immediately. Let's create the database and then run the app. We first need to use the migration generator to create the basic database:
$ ./script/generate hobo_migration
(Tip: Windows users: Whenever you see `./script/something`, you will need to instead do `ruby script/something`)
Respond to the prompt with `m` and then give the migration a name. Then:
$ ./script/server
You should be able to sign up. In the next section we'll be starting to flesh out the basics of the app.
---
db/migrate/20091201020248_initial_migration.rb | 22 ++++++++++++++++++
db/schema.rb | 30 ++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
create mode 100644 db/migrate/20091201020248_initial_migration.rb
create mode 100644 db/schema.rb
diff --git a/db/migrate/20091201020248_initial_migration.rb b/db/migrate/20091201020248_initial_migration.rb
new file mode 100644
index 0000000..2dc45a5
--- /dev/null
+++ b/db/migrate/20091201020248_initial_migration.rb
@@ -0,0 +1,22 @@
+class InitialMigration < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.string :crypted_password, :limit => 40
+ t.string :salt, :limit => 40
+ t.string :remember_token
+ t.datetime :remember_token_expires_at
+ t.string :name
+ t.string :email_address
+ t.boolean :administrator, :default => false
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.string :state, :default => "active"
+ t.datetime :key_timestamp
+ end
+ add_index :users, [:state]
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..10ba9ae
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,30 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20091201020248) do
+
+ create_table "users", :force => true do |t|
+ t.string "crypted_password", :limit => 40
+ t.string "salt", :limit => 40
+ t.string "remember_token"
+ t.datetime "remember_token_expires_at"
+ t.string "name"
+ t.string "email_address"
+ t.boolean "administrator", :default => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "state", :default => "active"
+ t.datetime "key_timestamp"
+ end
+
+ add_index "users", ["state"], :name => "index_users_on_state"
+
+end