20120101000001_create_base.rb 28 KB

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