20120101000001_create_base.rb 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. class CreateBase < ActiveRecord::Migration
  2. def up
  3. # clear old caches to start from scratch
  4. Cache.clear
  5. create_table :sessions do |t|
  6. t.string :session_id, null: false
  7. t.boolean :persistent, null: true
  8. t.text :data
  9. t.timestamps null: false
  10. end
  11. add_index :sessions, :session_id
  12. add_index :sessions, :updated_at
  13. add_index :sessions, :persistent
  14. create_table :users do |t|
  15. t.references :organization, null: true
  16. t.string :login, limit: 255, null: false
  17. t.string :firstname, limit: 100, null: true, default: ''
  18. t.string :lastname, limit: 100, null: true, default: ''
  19. t.string :email, limit: 255, null: true, default: ''
  20. t.string :image, limit: 100, null: true
  21. t.string :image_source, limit: 200, null: true
  22. t.string :web, limit: 100, null: true, default: ''
  23. t.string :password, limit: 100, null: true
  24. t.string :phone, limit: 100, null: true, default: ''
  25. t.string :fax, limit: 100, null: true, default: ''
  26. t.string :mobile, limit: 100, null: true, default: ''
  27. t.string :department, limit: 200, null: true, default: ''
  28. t.string :street, limit: 120, null: true, default: ''
  29. t.string :zip, limit: 100, null: true, default: ''
  30. t.string :city, limit: 100, null: true, default: ''
  31. t.string :country, limit: 100, null: true, default: ''
  32. t.string :address, limit: 500, null: true, default: ''
  33. t.boolean :vip, default: false
  34. t.boolean :verified, null: false, default: false
  35. t.boolean :active, null: false, default: true
  36. t.string :note, limit: 250, null: true, default: ''
  37. t.timestamp :last_login, limit: 3, null: true
  38. t.string :source, limit: 200, null: true
  39. t.integer :login_failed, null: false, default: 0
  40. t.string :preferences, limit: 8000, null: true
  41. t.integer :updated_by_id, null: false
  42. t.integer :created_by_id, null: false
  43. t.timestamps limit: 3, null: false
  44. end
  45. add_index :users, [:login], unique: true
  46. add_index :users, [:email]
  47. #add_index :users, [:email], unique: => true
  48. add_index :users, [:organization_id]
  49. add_index :users, [:image]
  50. add_index :users, [:department]
  51. add_index :users, [:phone]
  52. add_index :users, [:fax]
  53. add_index :users, [:mobile]
  54. add_index :users, [:source]
  55. add_index :users, [:created_by_id]
  56. create_table :signatures do |t|
  57. t.string :name, limit: 100, null: false
  58. t.text :body, limit: 10.megabytes + 1, null: true
  59. t.boolean :active, null: false, default: true
  60. t.string :note, limit: 250, null: true
  61. t.integer :updated_by_id, null: false
  62. t.integer :created_by_id, null: false
  63. t.timestamps limit: 3, null: false
  64. end
  65. add_index :signatures, [:name], unique: true
  66. create_table :email_addresses do |t|
  67. t.integer :channel_id, null: true
  68. t.string :realname, limit: 250, null: false
  69. t.string :email, limit: 250, null: false
  70. t.boolean :active, null: false, default: true
  71. t.string :note, limit: 250, null: true
  72. t.string :preferences, limit: 2000, null: true
  73. t.integer :updated_by_id, null: false
  74. t.integer :created_by_id, null: false
  75. t.timestamps limit: 3, null: false
  76. end
  77. add_index :email_addresses, [:email], unique: true
  78. create_table :groups do |t|
  79. t.references :signature, null: true
  80. t.references :email_address, null: true
  81. t.string :name, limit: 160, null: false
  82. t.integer :assignment_timeout, null: true
  83. t.string :follow_up_possible, limit: 100, null: false, default: 'yes'
  84. t.boolean :follow_up_assignment, null: false, default: true
  85. t.boolean :active, null: false, default: true
  86. t.string :note, limit: 250, null: true
  87. t.integer :updated_by_id, null: false
  88. t.integer :created_by_id, null: false
  89. t.timestamps limit: 3, null: false
  90. end
  91. add_index :groups, [:name], unique: true
  92. create_table :roles do |t|
  93. t.string :name, limit: 100, null: false
  94. t.text :preferences, limit: 500.kilobytes + 1, null: true
  95. t.boolean :default_at_signup, null: true, default: false
  96. t.boolean :active, null: false, default: true
  97. t.string :note, limit: 250, null: true
  98. t.integer :updated_by_id, null: false
  99. t.integer :created_by_id, null: false
  100. t.timestamps limit: 3, null: false
  101. end
  102. add_index :roles, [:name], unique: true
  103. create_table :permissions do |t|
  104. t.string :name, limit: 255, null: false
  105. t.string :note, limit: 500, null: true
  106. t.string :preferences, limit: 10_000, null: true
  107. t.boolean :active, null: false, default: true
  108. t.timestamps limit: 3, null: false
  109. end
  110. add_index :permissions, [:name], unique: true
  111. create_table :permissions_roles, id: false do |t|
  112. t.belongs_to :role, index: true
  113. t.belongs_to :permission, index: true
  114. end
  115. create_table :organizations do |t|
  116. t.string :name, limit: 100, null: false
  117. t.boolean :shared, null: false, default: true
  118. t.string :domain, limit: 250, null: true, default: ''
  119. t.boolean :domain_assignment, null: false, default: false
  120. t.boolean :active, null: false, default: true
  121. t.string :note, limit: 250, null: true, default: ''
  122. t.integer :updated_by_id, null: false
  123. t.integer :created_by_id, null: false
  124. t.timestamps limit: 3, null: false
  125. end
  126. add_index :organizations, [:name], unique: true
  127. add_index :organizations, [:domain]
  128. create_table :roles_users, id: false do |t|
  129. t.integer :user_id
  130. t.integer :role_id
  131. end
  132. add_index :roles_users, [:user_id]
  133. add_index :roles_users, [:role_id]
  134. create_table :groups_users, id: false do |t|
  135. t.integer :user_id
  136. t.integer :group_id
  137. end
  138. add_index :groups_users, [:user_id]
  139. add_index :groups_users, [:group_id]
  140. create_table :organizations_users, id: false do |t|
  141. t.integer :user_id
  142. t.integer :organization_id
  143. end
  144. add_index :organizations_users, [:user_id]
  145. add_index :organizations_users, [:organization_id]
  146. create_table :authorizations do |t|
  147. t.string :provider, limit: 250, null: false
  148. t.string :uid, limit: 250, null: false
  149. t.string :token, limit: 250, null: true
  150. t.string :secret, limit: 250, null: true
  151. t.string :username, limit: 250, null: true
  152. t.references :user, null: false
  153. t.timestamps limit: 3, null: false
  154. end
  155. add_index :authorizations, [:uid, :provider]
  156. add_index :authorizations, [:user_id]
  157. add_index :authorizations, [:username]
  158. create_table :locales do |t|
  159. t.string :locale, limit: 20, null: false
  160. t.string :alias, limit: 20, null: true
  161. t.string :name, limit: 255, null: false
  162. t.boolean :active, null: false, default: true
  163. t.timestamps limit: 3, null: false
  164. end
  165. add_index :locales, [:locale], unique: true
  166. add_index :locales, [:name], unique: true
  167. create_table :translations do |t|
  168. t.string :locale, limit: 10, null: false
  169. t.string :source, limit: 500, null: false
  170. t.string :target, limit: 500, null: false
  171. t.string :target_initial, limit: 500, null: false
  172. t.string :format, limit: 20, null: false, default: 'string'
  173. t.integer :updated_by_id, null: false
  174. t.integer :created_by_id, null: false
  175. t.timestamps limit: 3, null: false
  176. end
  177. add_index :translations, [:source], length: 255
  178. add_index :translations, [:locale]
  179. create_table :object_lookups do |t|
  180. t.string :name, limit: 250, null: false
  181. t.timestamps limit: 3, null: false
  182. end
  183. add_index :object_lookups, [:name], unique: true
  184. create_table :type_lookups do |t|
  185. t.string :name, limit: 250, null: false
  186. t.timestamps limit: 3, null: false
  187. end
  188. add_index :type_lookups, [:name], unique: true
  189. create_table :tokens do |t|
  190. t.references :user, null: false
  191. t.boolean :persistent
  192. t.string :name, limit: 100, null: false
  193. t.string :action, limit: 40, null: false
  194. t.string :label, limit: 255, null: true
  195. t.text :preferences, limit: 500.kilobytes + 1, null: true
  196. t.timestamp :last_used_at, limit: 3, null: true
  197. t.date :expires_at, null: true
  198. t.timestamps limit: 3, null: false
  199. end
  200. add_index :tokens, :user_id
  201. add_index :tokens, [:name, :action], unique: true
  202. add_index :tokens, :created_at
  203. add_index :tokens, :persistent
  204. create_table :packages do |t|
  205. t.string :name, limit: 250, null: false
  206. t.string :version, limit: 50, null: false
  207. t.string :vendor, limit: 150, null: false
  208. t.string :state, limit: 50, null: false
  209. t.integer :updated_by_id, null: false
  210. t.integer :created_by_id, null: false
  211. t.timestamps limit: 3, null: false
  212. end
  213. create_table :package_migrations do |t|
  214. t.string :name, limit: 250, null: false
  215. t.string :version, limit: 250, null: false
  216. t.timestamps limit: 3, null: false
  217. end
  218. create_table :taskbars do |t|
  219. t.integer :user_id, null: false
  220. t.datetime :last_contact, null: false
  221. t.string :client_id, null: false
  222. t.string :key, limit: 100, null: false
  223. t.string :callback, limit: 100, null: false
  224. t.text :state, limit: 20.megabytes + 1, null: true
  225. t.string :params, limit: 2000, null: true
  226. t.integer :prio, null: false
  227. t.boolean :notify, null: false, default: false
  228. t.boolean :active, null: false, default: false
  229. t.timestamps limit: 3, null: false
  230. end
  231. add_index :taskbars, [:user_id]
  232. add_index :taskbars, [:client_id]
  233. create_table :tags do |t|
  234. t.references :tag_item, null: false
  235. t.references :tag_object, null: false
  236. t.integer :o_id, null: false
  237. t.integer :created_by_id, null: false
  238. t.timestamps limit: 3, null: false
  239. end
  240. add_index :tags, [:o_id]
  241. add_index :tags, [:tag_object_id]
  242. create_table :tag_objects do |t|
  243. t.string :name, limit: 250, null: false
  244. t.timestamps limit: 3, null: false
  245. end
  246. add_index :tag_objects, [:name], unique: true
  247. create_table :tag_items do |t|
  248. t.string :name, limit: 250, null: false
  249. t.string :name_downcase, limit: 250, null: false
  250. t.timestamps limit: 3, null: false
  251. end
  252. add_index :tag_items, [:name_downcase]
  253. create_table :recent_views do |t|
  254. t.references :recent_view_object, null: false
  255. t.integer :o_id, null: false
  256. t.integer :created_by_id, null: false
  257. t.timestamps limit: 3, null: false
  258. end
  259. add_index :recent_views, [:o_id]
  260. add_index :recent_views, [:created_by_id]
  261. add_index :recent_views, [:created_at]
  262. add_index :recent_views, [:recent_view_object_id]
  263. create_table :activity_streams do |t|
  264. t.references :activity_stream_type, null: false
  265. t.references :activity_stream_object, null: false
  266. t.references :permission, null: true
  267. t.references :group, null: true
  268. t.integer :o_id, null: false
  269. t.integer :created_by_id, null: false
  270. t.timestamps limit: 3, null: false
  271. end
  272. add_index :activity_streams, [:o_id]
  273. add_index :activity_streams, [:created_by_id]
  274. add_index :activity_streams, [:permission_id]
  275. add_index :activity_streams, [:group_id]
  276. add_index :activity_streams, [:created_at]
  277. add_index :activity_streams, [:activity_stream_object_id]
  278. add_index :activity_streams, [:activity_stream_type_id]
  279. create_table :histories do |t|
  280. t.references :history_type, null: false
  281. t.references :history_object, null: false
  282. t.references :history_attribute, null: true
  283. t.integer :o_id, null: false
  284. t.integer :related_o_id, null: true
  285. t.integer :related_history_object_id, null: true
  286. t.integer :id_to, null: true
  287. t.integer :id_from, null: true
  288. t.string :value_from, limit: 500, null: true
  289. t.string :value_to, limit: 500, null: true
  290. t.integer :created_by_id, null: false
  291. t.timestamps limit: 3, null: false
  292. end
  293. add_index :histories, [:o_id]
  294. add_index :histories, [:created_by_id]
  295. add_index :histories, [:created_at]
  296. add_index :histories, [:history_object_id]
  297. add_index :histories, [:history_attribute_id]
  298. add_index :histories, [:history_type_id]
  299. add_index :histories, [:id_to]
  300. add_index :histories, [:id_from]
  301. add_index :histories, [:value_from], length: 255
  302. add_index :histories, [:value_to], length: 255
  303. create_table :history_types do |t|
  304. t.string :name, limit: 250, null: false
  305. t.timestamps limit: 3, null: false
  306. end
  307. add_index :history_types, [:name], unique: true
  308. create_table :history_objects do |t|
  309. t.string :name, limit: 250, null: false
  310. t.string :note, limit: 250, null: true
  311. t.timestamps limit: 3, null: false
  312. end
  313. add_index :history_objects, [:name], unique: true
  314. create_table :history_attributes do |t|
  315. t.string :name, limit: 250, null: false
  316. t.timestamps limit: 3, null: false
  317. end
  318. add_index :history_attributes, [:name], unique: true
  319. create_table :settings do |t|
  320. t.string :title, limit: 200, null: false
  321. t.string :name, limit: 200, null: false
  322. t.string :area, limit: 100, null: false
  323. t.string :description, limit: 2000, null: false
  324. t.string :options, limit: 2000, null: true
  325. t.text :state_current, limit: 200.kilobytes + 1, null: true
  326. t.string :state_initial, limit: 2000, null: true
  327. t.boolean :frontend, null: false
  328. t.text :preferences, limit: 200.kilobytes + 1, null: true
  329. t.timestamps limit: 3, null: false
  330. end
  331. add_index :settings, [:name], unique: true
  332. add_index :settings, [:area]
  333. add_index :settings, [:frontend]
  334. create_table :stores do |t|
  335. t.references :store_object, null: false
  336. t.references :store_file, null: false
  337. t.integer :o_id, limit: 8, null: false
  338. t.string :preferences, limit: 2500, null: true
  339. t.string :size, limit: 50, null: true
  340. t.string :filename, limit: 250, null: false
  341. t.integer :created_by_id, null: false
  342. t.timestamps limit: 3, null: false
  343. end
  344. add_index :stores, [:store_object_id, :o_id]
  345. create_table :store_objects do |t|
  346. t.string :name, limit: 250, null: false
  347. t.string :note, limit: 250, null: true
  348. t.timestamps limit: 3, null: false
  349. end
  350. add_index :store_objects, [:name], unique: true
  351. create_table :store_files do |t|
  352. t.string :sha, limit: 128, null: false
  353. t.string :provider, limit: 20, null: true
  354. t.timestamps limit: 3, null: false
  355. end
  356. add_index :store_files, [:sha], unique: true
  357. add_index :store_files, [:provider]
  358. create_table :store_provider_dbs do |t|
  359. t.string :sha, limit: 128, null: false
  360. t.binary :data, limit: 200.megabytes, null: true
  361. t.timestamps limit: 3, null: false
  362. end
  363. add_index :store_provider_dbs, [:sha], unique: true
  364. create_table :avatars do |t|
  365. t.integer :o_id, null: false
  366. t.integer :object_lookup_id, null: false
  367. t.boolean :default, null: false, default: false
  368. t.boolean :deletable, null: false, default: true
  369. t.boolean :initial, null: false, default: false
  370. t.integer :store_full_id, null: true
  371. t.integer :store_resize_id, null: true
  372. t.string :store_hash, limit: 32, null: true
  373. t.string :source, limit: 100, null: false
  374. t.string :source_url, limit: 512, null: true
  375. t.integer :updated_by_id, null: false
  376. t.integer :created_by_id, null: false
  377. t.timestamps limit: 3, null: false
  378. end
  379. add_index :avatars, [:o_id, :object_lookup_id]
  380. add_index :avatars, [:store_hash]
  381. add_index :avatars, [:source]
  382. add_index :avatars, [:default]
  383. create_table :online_notifications do |t|
  384. t.integer :o_id, null: false
  385. t.integer :object_lookup_id, null: false
  386. t.integer :type_lookup_id, null: false
  387. t.integer :user_id, null: false
  388. t.boolean :seen, null: false, default: false
  389. t.integer :updated_by_id, null: false
  390. t.integer :created_by_id, null: false
  391. t.timestamps limit: 3, null: false
  392. end
  393. add_index :online_notifications, [:user_id]
  394. add_index :online_notifications, [:seen]
  395. add_index :online_notifications, [:created_at]
  396. add_index :online_notifications, [:updated_at]
  397. create_table :schedulers do |t|
  398. t.string :name, limit: 250, null: false
  399. t.string :method, limit: 250, null: false
  400. t.integer :period, null: true
  401. t.integer :running, null: false, default: false
  402. t.timestamp :last_run, limit: 3, null: true
  403. t.integer :prio, null: false
  404. t.string :pid, limit: 250, null: true
  405. t.string :note, limit: 250, null: true
  406. t.boolean :active, null: false, default: false
  407. t.integer :updated_by_id, null: false
  408. t.integer :created_by_id, null: false
  409. t.timestamps limit: 3, null: false
  410. end
  411. add_index :schedulers, [:name], unique: true
  412. create_table :calendars do |t|
  413. t.string :name, limit: 250, null: true
  414. t.string :timezone, limit: 250, null: true
  415. t.string :business_hours, limit: 3000, null: true
  416. t.boolean :default, null: false, default: false
  417. t.string :ical_url, limit: 500, null: true
  418. t.text :public_holidays, limit: 500.kilobytes + 1, null: true
  419. t.text :last_log, limit: 500.kilobytes + 1, null: true
  420. t.timestamp :last_sync, limit: 3, null: true
  421. t.integer :updated_by_id, null: false
  422. t.integer :created_by_id, null: false
  423. t.timestamps limit: 3, null: false
  424. end
  425. add_index :calendars, [:name], unique: true
  426. create_table :user_devices do |t|
  427. t.references :user, null: false
  428. t.string :name, limit: 250, null: false
  429. t.string :os, limit: 150, null: true
  430. t.string :browser, limit: 250, null: true
  431. t.string :location, limit: 150, null: true
  432. t.string :device_details, limit: 2500, null: true
  433. t.string :location_details, limit: 2500, null: true
  434. t.string :fingerprint, limit: 160, null: true
  435. t.string :user_agent, limit: 250, null: true
  436. t.string :ip, limit: 160, null: true
  437. t.timestamps limit: 3, null: false
  438. end
  439. add_index :user_devices, [:user_id]
  440. add_index :user_devices, [:os, :browser, :location]
  441. add_index :user_devices, [:fingerprint]
  442. add_index :user_devices, [:updated_at]
  443. add_index :user_devices, [:created_at]
  444. create_table :external_credentials do |t|
  445. t.string :name
  446. t.string :credentials, limit: 2500, null: false
  447. t.timestamps limit: 3, null: false
  448. end
  449. create_table :object_manager_attributes do |t|
  450. t.references :object_lookup, null: false
  451. t.string :name, limit: 200, null: false
  452. t.string :display, limit: 200, null: false
  453. t.string :data_type, limit: 100, null: false
  454. t.string :data_option, limit: 8000, null: true
  455. t.string :data_option_new, limit: 8000, null: true
  456. t.boolean :editable, null: false, default: true
  457. t.boolean :active, null: false, default: true
  458. t.string :screens, limit: 2000, null: true
  459. t.boolean :to_create, null: false, default: false
  460. t.boolean :to_migrate, null: false, default: false
  461. t.boolean :to_delete, null: false, default: false
  462. t.boolean :to_config, null: false, default: false
  463. t.integer :position, null: false
  464. t.integer :created_by_id, null: false
  465. t.integer :updated_by_id, null: false
  466. t.timestamps limit: 3, null: false
  467. end
  468. add_index :object_manager_attributes, [:object_lookup_id, :name], unique: true
  469. add_index :object_manager_attributes, [:object_lookup_id]
  470. create_table :delayed_jobs, force: true do |t|
  471. t.integer :priority, default: 0 # Allows some jobs to jump to the front of the queue
  472. t.integer :attempts, default: 0 # Provides for retries, but still fail eventually.
  473. t.text :handler # YAML-encoded string of the object that will do work
  474. t.text :last_error # reason for last failure (See Note below)
  475. t.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
  476. t.datetime :locked_at # Set when a client is working on this object
  477. t.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
  478. t.string :locked_by # Who is working on this object (if locked)
  479. t.string :queue # The name of the queue this job is in
  480. t.timestamps limit: 3, null: false
  481. end
  482. add_index :delayed_jobs, [:priority, :run_at], name: 'delayed_jobs_priority'
  483. create_table :external_syncs do |t|
  484. t.string :source, limit: 100, null: false
  485. t.string :source_id, limit: 200, null: false
  486. t.string :object, limit: 100, null: false
  487. t.integer :o_id, null: false
  488. t.text :last_payload, limit: 500.kilobytes + 1, null: true
  489. t.timestamps limit: 3, null: false
  490. end
  491. add_index :external_syncs, [:source, :source_id], unique: true
  492. add_index :external_syncs, [:source, :source_id, :object, :o_id], name: 'index_external_syncs_on_source_and_source_id_and_object_o_id'
  493. add_index :external_syncs, [:object, :o_id]
  494. create_table :cti_logs do |t|
  495. t.string :direction, limit: 20, null: false
  496. t.string :state, limit: 20, null: false
  497. t.string :from, limit: 100, null: false
  498. t.string :from_comment, limit: 250, null: true
  499. t.string :to, limit: 100, null: false
  500. t.string :to_comment, limit: 250, null: true
  501. t.string :call_id, limit: 250, null: false
  502. t.string :comment, limit: 500, null: true
  503. t.timestamp :start, limit: 3, null: true
  504. t.timestamp :end, limit: 3, null: true
  505. t.boolean :done, null: false, default: true
  506. t.text :preferences, limit: 500.kilobytes + 1, null: true
  507. t.timestamps limit: 3, null: false
  508. end
  509. add_index :cti_logs, [:call_id], unique: true
  510. add_index :cti_logs, [:direction]
  511. add_index :cti_logs, [:from]
  512. create_table :cti_caller_ids do |t|
  513. t.string :caller_id, limit: 100, null: false
  514. t.string :comment, limit: 500, null: true
  515. t.string :level, limit: 100, null: false
  516. t.string :object, limit: 100, null: false
  517. t.integer :o_id, null: false
  518. t.integer :user_id, null: true
  519. t.text :preferences, limit: 500.kilobytes + 1, null: true
  520. t.timestamps limit: 3, null: false
  521. end
  522. add_index :cti_caller_ids, [:caller_id]
  523. add_index :cti_caller_ids, [:caller_id, :level]
  524. add_index :cti_caller_ids, [:caller_id, :user_id]
  525. add_index :cti_caller_ids, [:object, :o_id]
  526. create_table :stats_stores do |t|
  527. t.references :stats_store_object, null: false
  528. t.integer :o_id, null: false
  529. t.string :key, limit: 250, null: true
  530. t.integer :related_o_id, null: true
  531. t.integer :related_stats_store_object_id, null: true
  532. t.string :data, limit: 5000, null: true
  533. t.integer :created_by_id, null: false
  534. t.timestamps limit: 3, null: false
  535. end
  536. add_index :stats_stores, [:o_id]
  537. add_index :stats_stores, [:key]
  538. add_index :stats_stores, [:stats_store_object_id]
  539. add_index :stats_stores, [:created_by_id]
  540. add_index :stats_stores, [:created_at]
  541. create_table :http_logs do |t|
  542. t.column :direction, :string, limit: 20, null: false
  543. t.column :facility, :string, limit: 100, null: false
  544. t.column :method, :string, limit: 100, null: false
  545. t.column :url, :string, limit: 255, null: false
  546. t.column :status, :string, limit: 20, null: true
  547. t.column :ip, :string, limit: 50, null: true
  548. t.column :request, :string, limit: 10_000, null: false
  549. t.column :response, :string, limit: 10_000, null: false
  550. t.column :updated_by_id, :integer, null: true
  551. t.column :created_by_id, :integer, null: true
  552. t.timestamps limit: 3, null: false
  553. end
  554. add_index :http_logs, [:facility]
  555. add_index :http_logs, [:created_by_id]
  556. add_index :http_logs, [:created_at]
  557. end
  558. end