schema.rb 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # encoding: UTF-8
  2. # This file is auto-generated from the current state of the database. Instead
  3. # of editing this file, please use the migrations feature of Active Record to
  4. # incrementally modify your database, and then regenerate this schema definition.
  5. #
  6. # Note that this schema.rb definition is the authoritative source for your
  7. # database schema. If you need to create the application database on another
  8. # system, you should be using db:schema:load, not running all the migrations
  9. # from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10. # you'll amass, the slower it'll run and the greater likelihood for issues).
  11. #
  12. # It's strongly recommended that you check this file into your version control system.
  13. ActiveRecord::Schema.define(version: 20140901143732) do
  14. # These are extensions that must be enabled in order to support this database
  15. enable_extension "plpgsql"
  16. create_table "agent_logs", force: true do |t|
  17. t.integer "agent_id", null: false
  18. t.text "message", limit: 16777215, null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
  19. t.integer "level", default: 3, null: false
  20. t.integer "inbound_event_id"
  21. t.integer "outbound_event_id"
  22. t.datetime "created_at"
  23. t.datetime "updated_at"
  24. end
  25. create_table "agents", force: true do |t|
  26. t.integer "user_id"
  27. t.text "options", limit: 16777215, charset: "utf8mb4", collation: "utf8mb4_bin"
  28. t.string "type", collation: "utf8_bin"
  29. t.string "name", charset: "utf8mb4", collation: "utf8mb4_bin"
  30. t.string "schedule", collation: "utf8_bin"
  31. t.integer "events_count", default: 0, null: false
  32. t.datetime "last_check_at"
  33. t.datetime "last_receive_at"
  34. t.integer "last_checked_event_id"
  35. t.datetime "created_at", null: false
  36. t.datetime "updated_at", null: false
  37. t.text "memory", limit: 2147483647, charset: "utf8mb4", collation: "utf8mb4_bin"
  38. t.datetime "last_web_request_at"
  39. t.integer "keep_events_for", default: 0, null: false
  40. t.datetime "last_event_at"
  41. t.datetime "last_error_log_at"
  42. t.boolean "propagate_immediately", default: false, null: false
  43. t.boolean "disabled", default: false, null: false
  44. t.string "guid", null: false, charset: "ascii", collation: "ascii_bin"
  45. t.integer "service_id"
  46. end
  47. add_index "agents", ["guid"], name: "index_agents_on_guid", using: :btree
  48. add_index "agents", ["schedule"], name: "index_agents_on_schedule", using: :btree
  49. add_index "agents", ["type"], name: "index_agents_on_type", using: :btree
  50. add_index "agents", ["user_id", "created_at"], name: "index_agents_on_user_id_and_created_at", using: :btree
  51. create_table "control_links", force: true do |t|
  52. t.integer "controller_id", null: false
  53. t.integer "control_target_id", null: false
  54. t.datetime "created_at"
  55. t.datetime "updated_at"
  56. end
  57. add_index "control_links", ["control_target_id"], name: "index_control_links_on_control_target_id", using: :btree
  58. add_index "control_links", ["controller_id", "control_target_id"], name: "index_control_links_on_controller_id_and_control_target_id", unique: true, using: :btree
  59. create_table "delayed_jobs", force: true do |t|
  60. t.integer "priority", default: 0
  61. t.integer "attempts", default: 0
  62. t.text "handler", limit: 16777215, charset: "utf8mb4", collation: "utf8mb4_bin"
  63. t.text "last_error", limit: 16777215, charset: "utf8mb4", collation: "utf8mb4_bin"
  64. t.datetime "run_at"
  65. t.datetime "locked_at"
  66. t.datetime "failed_at"
  67. t.string "locked_by"
  68. t.string "queue"
  69. t.datetime "created_at"
  70. t.datetime "updated_at"
  71. end
  72. add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
  73. create_table "events", force: true do |t|
  74. t.integer "user_id"
  75. t.integer "agent_id"
  76. t.decimal "lat", precision: 15, scale: 10
  77. t.decimal "lng", precision: 15, scale: 10
  78. t.text "payload", limit: 2147483647, charset: "utf8mb4", collation: "utf8mb4_bin"
  79. t.datetime "created_at", null: false
  80. t.datetime "updated_at", null: false
  81. t.datetime "expires_at"
  82. end
  83. add_index "events", ["agent_id", "created_at"], name: "index_events_on_agent_id_and_created_at", using: :btree
  84. add_index "events", ["expires_at"], name: "index_events_on_expires_at", using: :btree
  85. add_index "events", ["user_id", "created_at"], name: "index_events_on_user_id_and_created_at", using: :btree
  86. create_table "links", force: true do |t|
  87. t.integer "source_id"
  88. t.integer "receiver_id"
  89. t.datetime "created_at"
  90. t.datetime "updated_at"
  91. t.integer "event_id_at_creation", default: 0, null: false
  92. end
  93. add_index "links", ["receiver_id", "source_id"], name: "index_links_on_receiver_id_and_source_id", using: :btree
  94. add_index "links", ["source_id", "receiver_id"], name: "index_links_on_source_id_and_receiver_id", using: :btree
  95. create_table "scenario_memberships", force: true do |t|
  96. t.integer "agent_id", null: false
  97. t.integer "scenario_id", null: false
  98. t.datetime "created_at"
  99. t.datetime "updated_at"
  100. end
  101. add_index "scenario_memberships", ["agent_id"], name: "index_scenario_memberships_on_agent_id", using: :btree
  102. add_index "scenario_memberships", ["scenario_id"], name: "index_scenario_memberships_on_scenario_id", using: :btree
  103. create_table "scenarios", force: true do |t|
  104. t.string "name", null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
  105. t.integer "user_id", null: false
  106. t.datetime "created_at"
  107. t.datetime "updated_at"
  108. t.text "description", charset: "utf8mb4", collation: "utf8mb4_bin"
  109. t.boolean "public", default: false, null: false
  110. t.string "guid", null: false, charset: "ascii", collation: "ascii_bin"
  111. t.string "source_url"
  112. t.string "tag_bg_color"
  113. t.string "tag_fg_color"
  114. end
  115. add_index "scenarios", ["user_id", "guid"], name: "index_scenarios_on_user_id_and_guid", unique: true, using: :btree
  116. create_table "services", force: true do |t|
  117. t.integer "user_id", null: false
  118. t.string "provider", null: false
  119. t.string "name", null: false
  120. t.text "token", null: false
  121. t.text "secret"
  122. t.text "refresh_token"
  123. t.datetime "expires_at"
  124. t.boolean "global", default: false
  125. t.text "options"
  126. t.datetime "created_at"
  127. t.datetime "updated_at"
  128. t.string "uid"
  129. end
  130. add_index "services", ["provider"], name: "index_services_on_provider", using: :btree
  131. add_index "services", ["uid"], name: "index_services_on_uid", using: :btree
  132. add_index "services", ["user_id", "global"], name: "index_services_on_user_id_and_global", using: :btree
  133. create_table "user_credentials", force: true do |t|
  134. t.integer "user_id", null: false
  135. t.string "credential_name", null: false
  136. t.text "credential_value", null: false
  137. t.datetime "created_at", null: false
  138. t.datetime "updated_at", null: false
  139. t.string "mode", default: "text", null: false, collation: "utf8_bin"
  140. end
  141. add_index "user_credentials", ["user_id", "credential_name"], name: "index_user_credentials_on_user_id_and_credential_name", unique: true, using: :btree
  142. create_table "users", force: true do |t|
  143. t.string "email", default: "", null: false, collation: "utf8_bin"
  144. t.string "encrypted_password", default: "", null: false, charset: "ascii", collation: "ascii_bin"
  145. t.string "reset_password_token", collation: "utf8_bin"
  146. t.datetime "reset_password_sent_at"
  147. t.datetime "remember_created_at"
  148. t.integer "sign_in_count", default: 0
  149. t.datetime "current_sign_in_at"
  150. t.datetime "last_sign_in_at"
  151. t.string "current_sign_in_ip"
  152. t.string "last_sign_in_ip"
  153. t.datetime "created_at", null: false
  154. t.datetime "updated_at", null: false
  155. t.boolean "admin", default: false, null: false
  156. t.integer "failed_attempts", default: 0
  157. t.string "unlock_token"
  158. t.datetime "locked_at"
  159. t.string "username", limit: 191, null: false, charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
  160. t.string "invitation_code", null: false, collation: "utf8_bin"
  161. t.integer "scenario_count", default: 0, null: false
  162. end
  163. add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  164. add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
  165. add_index "users", ["unlock_token"], name: "index_users_on_unlock_token", unique: true, using: :btree
  166. add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree
  167. end