summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20140306014123_add_index_to_users_email.rb4
-rw-r--r--db/migrate/20140306014125_add_index_to_users_user_name.rb3
-rw-r--r--db/migrate/20140306014128_add_password_digest_to_users.rb1
-rw-r--r--db/migrate/20140306014130_add_remember_token_to_users.rb4
-rw-r--r--db/schema.rb6
-rw-r--r--db/seeds.rb4
6 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20140306014123_add_index_to_users_email.rb b/db/migrate/20140306014123_add_index_to_users_email.rb
index b5f8a1a..934d23b 100644
--- a/db/migrate/20140306014123_add_index_to_users_email.rb
+++ b/db/migrate/20140306014123_add_index_to_users_email.rb
@@ -1,4 +1,8 @@
class AddIndexToUsersEmail < ActiveRecord::Migration
+
+# adding unique: true ensures there can be no duplicates
def change
+ add_index :users, :email, unique: true
end
+
end
diff --git a/db/migrate/20140306014125_add_index_to_users_user_name.rb b/db/migrate/20140306014125_add_index_to_users_user_name.rb
index 724cca5..22ca8c3 100644
--- a/db/migrate/20140306014125_add_index_to_users_user_name.rb
+++ b/db/migrate/20140306014125_add_index_to_users_user_name.rb
@@ -1,4 +1,7 @@
class AddIndexToUsersUserName < ActiveRecord::Migration
+
+# ensures that the username is unique
def change
+ add_index :users, :user_name, unique: true
end
end
diff --git a/db/migrate/20140306014128_add_password_digest_to_users.rb b/db/migrate/20140306014128_add_password_digest_to_users.rb
index 0070da7..7ad1f62 100644
--- a/db/migrate/20140306014128_add_password_digest_to_users.rb
+++ b/db/migrate/20140306014128_add_password_digest_to_users.rb
@@ -1,4 +1,5 @@
class AddPasswordDigestToUsers < ActiveRecord::Migration
def change
+ add_column :users, :password_digest, :string
end
end
diff --git a/db/migrate/20140306014130_add_remember_token_to_users.rb b/db/migrate/20140306014130_add_remember_token_to_users.rb
index 74c254f..6d84942 100644
--- a/db/migrate/20140306014130_add_remember_token_to_users.rb
+++ b/db/migrate/20140306014130_add_remember_token_to_users.rb
@@ -1,4 +1,8 @@
class AddRememberTokenToUsers < ActiveRecord::Migration
+ #add a remember me token to the database
+ #this keeps a user signed in until they sign out
def change
+ add_column :users, :remember_token, :string
+ add_index :users, :remember_token
end
end
diff --git a/db/schema.rb b/db/schema.rb
index e700a4a..f2e9136 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -124,6 +124,12 @@ ActiveRecord::Schema.define(version: 20140306014132) do
t.string "user_name"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "password_digest"
+ t.string "remember_token"
end
+ add_index "users", ["email"], name: "index_users_on_email", unique: true
+ add_index "users", ["remember_token"], name: "index_users_on_remember_token"
+ add_index "users", ["user_name"], name: "index_users_on_user_name", unique: true
+
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 4edb1e8..ab130a8 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,3 +5,7 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
+#
+Game.create(name: "League of Legends", players_per_team: 5, teams_per_match: 2, set_rounds: 1, randomized_teams: 0)
+
+