diff --git a/db/migrate/20150127180326_add_story_twitter_id.rb b/db/migrate/20150127180326_add_story_twitter_id.rb new file mode 100644 index 0000000..1707d95 --- /dev/null +++ b/db/migrate/20150127180326_add_story_twitter_id.rb @@ -0,0 +1,6 @@ +class AddStoryTwitterId < ActiveRecord::Migration + def change + add_column :stories, :twitter_id, :string, :limit => 20 + add_index :stories, [ :twitter_id ] + end +end diff --git a/db/schema.rb b/db/schema.rb index aa4fe2c..9a970a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150115172138) do +ActiveRecord::Schema.define(version: 20150127180326) do create_table "comments", force: true do |t| t.datetime "created_at", null: false @@ -115,12 +115,14 @@ ActiveRecord::Schema.define(version: 20150115172138) do t.integer "comments_count", default: 0, null: false t.integer "merged_story_id" t.datetime "unavailable_at" + t.string "twitter_id", limit: 20 end add_index "stories", ["hotness"], name: "hotness_idx", using: :btree add_index "stories", ["is_expired", "is_moderated"], name: "is_idxes", using: :btree add_index "stories", ["merged_story_id"], name: "index_stories_on_merged_story_id", using: :btree add_index "stories", ["short_id"], name: "unique_short_id", unique: true, using: :btree + add_index "stories", ["twitter_id"], name: "index_stories_on_twitter_id", using: :btree add_index "stories", ["url"], name: "url", length: {"url"=>191}, using: :btree create_table "tag_filters", force: true do |t| diff --git a/script/post_to_twitter b/script/post_to_twitter index 4cf74b5..877e5ed 100755 --- a/script/post_to_twitter +++ b/script/post_to_twitter @@ -48,7 +48,9 @@ order(:id).each do |s| { "status" => status }) begin - if !res["id_str"].match(/\d+/) + if res["id_str"].match(/\d+/) + s.update_column("twitter_id", res["id_str"]) + else raise end rescue => e