Skip to content

Commit c4751b5

Browse files
committed
adding api key
1 parent 83b8588 commit c4751b5

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require "digest/sha1"
2+
3+
class AddApiKeyToUsers < ActiveRecord::Migration
4+
def self.up
5+
add_column :users, :api_key, :string
6+
User.all.each do |u|
7+
u.api_key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..16]
8+
u.save
9+
end
10+
end
11+
12+
def self.down
13+
remove_column :users, :api_key
14+
end
15+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# It's strongly recommended to check this file into your version control system.
1111

12-
ActiveRecord::Schema.define(:version => 20091219060017) do
12+
ActiveRecord::Schema.define(:version => 20091219143931) do
1313

1414
create_table "comments", :force => true do |t|
1515
t.integer "user_id"
@@ -46,6 +46,7 @@
4646
t.string "persistence_token"
4747
t.datetime "created_at"
4848
t.datetime "updated_at"
49+
t.string "api_key"
4950
end
5051

5152
create_table "watches", :force => true do |t|

0 commit comments

Comments
 (0)