class HubStore::Storage::Database

Attributes

options[R]

Public Class Methods

new(options = { adapter: "sqlite3", database: "hub_store_db" }) click to toggle source
# File lib/hub_store/storage/database.rb, line 5
def initialize(options = { adapter: "sqlite3", database: "hub_store_db" })
  @options = options
end

Public Instance Methods

setup() click to toggle source
# File lib/hub_store/storage/database.rb, line 9
def setup
  connect
  create_tables
end

Private Instance Methods

connect() click to toggle source
# File lib/hub_store/storage/database.rb, line 18
def connect
  ActiveRecord::Base.establish_connection(options)
end
create_tables() click to toggle source
# File lib/hub_store/storage/database.rb, line 22
def create_tables
  ActiveRecord::Schema.define do
    unless ActiveRecord::Base.connection.table_exists?("pull_requests")
      create_table "pull_requests", force: :cascade do |t|
        t.string "title"
        t.string "submitter"
        t.string "number"
        t.string "labels"
        t.string "repo"
        t.string "state"
        t.string "html_url"
        t.integer "additions"
        t.integer "comments_count"
        t.integer "review_comments_count"
        t.datetime "closed_at"
        t.datetime "merged_at"
        t.datetime "created_at", null: false
        t.datetime "updated_at", null: false
      end
    end

    unless ActiveRecord::Base.connection.table_exists?("reviews")
      create_table "reviews", force: :cascade do |t|
        t.bigint "pull_request_id"
        t.datetime "submitted_at"
        t.string "reviewer"
        t.string "state"
        t.string "html_url"
        t.integer "review_comments_count"
        t.boolean "reply"
        t.text "body"
      end
    end
  end
end