forcast 0.0.110

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/COPYRIGHTS +11 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +166 -0
  6. data/PENDIENTES +39 -0
  7. data/README.md +35 -0
  8. data/Rakefile +7 -0
  9. data/VERSION +1 -0
  10. data/bin/console +14 -0
  11. data/bin/rake +28 -0
  12. data/bin/setup +8 -0
  13. data/forcast.gemspec +73 -0
  14. data/lib/forcast.rb +5 -0
  15. data/lib/forcast/controllers/all.rb +2 -0
  16. data/lib/forcast/controllers/application/all.rb +12 -0
  17. data/lib/forcast/controllers/application/crud.rb +91 -0
  18. data/lib/forcast/controllers/application/database.rb +34 -0
  19. data/lib/forcast/controllers/application/error.rb +18 -0
  20. data/lib/forcast/controllers/application/exception_handler.rb +25 -0
  21. data/lib/forcast/controllers/application/json.rb +83 -0
  22. data/lib/forcast/controllers/application/locale.rb +30 -0
  23. data/lib/forcast/controllers/application/log.rb +22 -0
  24. data/lib/forcast/controllers/application/login.rb +41 -0
  25. data/lib/forcast/controllers/application/meta.rb +61 -0
  26. data/lib/forcast/controllers/application/model.rb +17 -0
  27. data/lib/forcast/controllers/application/permitirtodo.rb +27 -0
  28. data/lib/forcast/controllers/application/utils.rb +28 -0
  29. data/lib/forcast/controllers/controller/all.rb +8 -0
  30. data/lib/forcast/controllers/controller/asociar.rb +121 -0
  31. data/lib/forcast/controllers/controller/busqueda.rb +151 -0
  32. data/lib/forcast/controllers/controller/definitor/definitor.rb +322 -0
  33. data/lib/forcast/controllers/controller/definitor/definitor_page.rb +40 -0
  34. data/lib/forcast/controllers/controller/definitor_all.rb +2 -0
  35. data/lib/forcast/controllers/controller/filtro.rb +48 -0
  36. data/lib/forcast/controllers/controller/login/controllers/base_controller.rb +135 -0
  37. data/lib/forcast/controllers/controller/login/controllers/login_controller.rb +38 -0
  38. data/lib/forcast/controllers/controller/login/login.rb +71 -0
  39. data/lib/forcast/controllers/controller/login_all.rb +1 -0
  40. data/lib/forcast/controllers/controller/paper_trail/paper_trail.rb +21 -0
  41. data/lib/forcast/controllers/controller/paper_trail_all.rb +1 -0
  42. data/lib/forcast/controllers/controller/relacion.rb +157 -0
  43. data/lib/forcast/controllers/controller/rule_engine/action_engine.rb +92 -0
  44. data/lib/forcast/controllers/controller/rule_engine/controllers/action_logs_controller.rb +12 -0
  45. data/lib/forcast/controllers/controller/rule_engine/controllers/actions_controller.rb +10 -0
  46. data/lib/forcast/controllers/controller/rule_engine/controllers/pollings_controller.rb +13 -0
  47. data/lib/forcast/controllers/controller/rule_engine/controllers/rule_logs_controller.rb +12 -0
  48. data/lib/forcast/controllers/controller/rule_engine/controllers/rules_controller.rb +19 -0
  49. data/lib/forcast/controllers/controller/rule_engine/controllers/webhooks_controller.rb +27 -0
  50. data/lib/forcast/controllers/controller/rule_engine/polling_engine.rb +76 -0
  51. data/lib/forcast/controllers/controller/rule_engine/rule_controller.rb +27 -0
  52. data/lib/forcast/controllers/controller/rule_engine/rule_engine.rb +88 -0
  53. data/lib/forcast/controllers/controller/rule_engine/webhook_engine.rb +38 -0
  54. data/lib/forcast/controllers/controller/rule_engine_all.rb +5 -0
  55. data/lib/forcast/jobs/all.rb +2 -0
  56. data/lib/forcast/jobs/jobs_assets.rb +25 -0
  57. data/lib/forcast/jobs/jobs_wrapper.rb +25 -0
  58. data/lib/forcast/jobs/rule_engine/jobs_actions.rb +73 -0
  59. data/lib/forcast/jobs/rule_engine/jobs_pollings.rb +77 -0
  60. data/lib/forcast/jobs/rule_engine/jobs_webhooks.rb +54 -0
  61. data/lib/forcast/migrations/0_migracion_general.rb +44 -0
  62. data/lib/forcast/migrations/paper_trail/versions.rb +61 -0
  63. data/lib/forcast/migrations/rule_engine/action_logs.rb +15 -0
  64. data/lib/forcast/migrations/rule_engine/actions.rb +15 -0
  65. data/lib/forcast/migrations/rule_engine/pollings.rb +26 -0
  66. data/lib/forcast/migrations/rule_engine/rule_logs.rb +22 -0
  67. data/lib/forcast/migrations/rule_engine/rules.rb +27 -0
  68. data/lib/forcast/migrations/rule_engine/webhooks.rb +25 -0
  69. data/lib/forcast/models/all.rb +8 -0
  70. data/lib/forcast/models/asociar.rb +74 -0
  71. data/lib/forcast/models/busqueda.rb +17 -0
  72. data/lib/forcast/models/login/authorization.rb +37 -0
  73. data/lib/forcast/models/login/json_web_token.rb +15 -0
  74. data/lib/forcast/models/login/login.rb +26 -0
  75. data/lib/forcast/models/login_all.rb +2 -0
  76. data/lib/forcast/models/meta.rb +19 -0
  77. data/lib/forcast/models/modelo.rb +125 -0
  78. data/lib/forcast/models/models/meta.rb +6 -0
  79. data/lib/forcast/models/paper_trail/paper_trail.rb +13 -0
  80. data/lib/forcast/models/paper_trail_all.rb +1 -0
  81. data/lib/forcast/models/permitirtodo.rb +57 -0
  82. data/lib/forcast/models/rule_engine/action_engine.rb +19 -0
  83. data/lib/forcast/models/rule_engine/models/action.rb +41 -0
  84. data/lib/forcast/models/rule_engine/models/action_log.rb +40 -0
  85. data/lib/forcast/models/rule_engine/models/polling.rb +43 -0
  86. data/lib/forcast/models/rule_engine/models/rule.rb +44 -0
  87. data/lib/forcast/models/rule_engine/models/rule_log.rb +39 -0
  88. data/lib/forcast/models/rule_engine/models/webhook.rb +43 -0
  89. data/lib/forcast/models/rule_engine/polling_engine.rb +113 -0
  90. data/lib/forcast/models/rule_engine/rule.rb +62 -0
  91. data/lib/forcast/models/rule_engine/rule_engine.rb +137 -0
  92. data/lib/forcast/models/rule_engine/rule_scope.rb +35 -0
  93. data/lib/forcast/models/rule_engine/webhook_engine.rb +55 -0
  94. data/lib/forcast/models/rule_engine_all.rb +6 -0
  95. data/lib/forcast/routes/concerns/asociar.rb +15 -0
  96. data/lib/forcast/routes/concerns/buscar.rb +6 -0
  97. data/lib/forcast/routes/concerns/definitor.rb +3 -0
  98. data/lib/forcast/routes/concerns/modelo.rb +6 -0
  99. data/lib/forcast/routes/database.rb +4 -0
  100. data/lib/forcast/routes/login.rb +4 -0
  101. data/lib/forcast/routes/paper_trail/paper_trail.rb +3 -0
  102. data/lib/forcast/routes/rule_engine/rule.rb +5 -0
  103. data/lib/forcast/tasks/.giosaveZr0hbs +21 -0
  104. data/lib/forcast/tasks/.keep +0 -0
  105. data/lib/forcast/tasks/all.rb +16 -0
  106. data/lib/forcast/tasks/diagramas.rake +32 -0
  107. data/lib/forcast/tasks/documentation/documentation.rb +100 -0
  108. data/lib/forcast/tasks/env.rake +10 -0
  109. data/lib/forcast/tasks/git.rake +22 -0
  110. data/lib/forcast/tasks/indy/indy.rb +28 -0
  111. data/lib/forcast/tasks/logs.rake +13 -0
  112. data/lib/forcast/tasks/process.rake +18 -0
  113. data/lib/forcast/tasks/schema.rake +17 -0
  114. data/lib/forcast/tasks/schema/recips/action.rb +18 -0
  115. data/lib/forcast/tasks/schema/recips/controller.rb +29 -0
  116. data/lib/forcast/tasks/schema/recips/definitor.rb +38 -0
  117. data/lib/forcast/tasks/schema/recips/model.rb +43 -0
  118. data/lib/forcast/tasks/schema/recips/project.rb +19 -0
  119. data/lib/forcast/tasks/schema/recips/route.rb +9 -0
  120. data/lib/forcast/tasks/schema/recips/tmp/controller.rb +0 -0
  121. data/lib/forcast/tasks/schema/recips/tmp/model.rb +0 -0
  122. data/lib/forcast/tasks/schema/recips/tmp/model/.keep +0 -0
  123. data/lib/forcast/tasks/schema/rule_engine/rule_engine.rb +98 -0
  124. data/lib/forcast/tasks/schema/schema.rb +346 -0
  125. data/lib/forcast/tasks/test.rake +129 -0
  126. data/lib/forcast/tasks/utils.rake +68 -0
  127. data/lib/forcast/tasks/yard.rake +18 -0
  128. data/lib/forcast/utils/all.rb +4 -0
  129. data/lib/forcast/utils/email.rb +49 -0
  130. data/lib/forcast/utils/email/forcast/utils/email/layout/default.html.erb +3 -0
  131. data/lib/forcast/utils/email/forcast/utils/email/layout/default.text.erb +5 -0
  132. data/lib/forcast/utils/firebase.rb +60 -0
  133. data/lib/forcast/utils/firebase_database.rb +117 -0
  134. data/lib/forcast/utils/measure.rb +44 -0
  135. data/lib/forcast/utils/qvo.rb +141 -0
  136. data/lib/forcast/utils/server.rb +296 -0
  137. data/lib/forcast/utils/telegram.rb +82 -0
  138. data/lib/forcast/utils/thing.rb +180 -0
  139. data/lib/forcast/version.rb +15 -0
  140. data/lib/lib/backup.rb +42 -0
  141. data/lib/lib/deploy.sh +40 -0
  142. data/lib/lib/forcast_servidor_rails.sh +11 -0
  143. data/lib/lib/pg_generator.sh +10 -0
  144. data/lib/lib/production.rb +66 -0
  145. data/lib/lib/production/production.rb +30 -0
  146. data/lib/lib/systemctl_maker.rb +88 -0
  147. data/lib/lib/update.rb +100 -0
  148. data/production.rb +31 -0
  149. metadata +301 -0
@@ -0,0 +1,25 @@
1
+ require 'sidekiq'
2
+ require 'active_job'
3
+ include Sidekiq::Worker
4
+
5
+ module Forcast
6
+ module Jobs
7
+ module JobsWrapper
8
+ class Repetitive < ActiveJob::Base
9
+ sidekiq_options queue: 'sync_repetitive'
10
+ def perform(callback,array,t,interval,unidad)
11
+ vas = eval(callback)
12
+ unidad = 'minutes' unless units.include?(unidad)
13
+ i = interval || 1
14
+ t = (t/i).round || 1
15
+ t.times do |time|
16
+ vas.perform_at(((time+1)*interval).send(unidad).from_now,array)
17
+ end
18
+ end
19
+ def units
20
+ return ['seconds','minutes','hours','days']
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,73 @@
1
+ require 'sidekiq'
2
+ require 'date'
3
+
4
+ include Sidekiq::Worker
5
+
6
+ module JobsActions
7
+ class Actions < ActiveJob::Base
8
+ sidekiq_options queue: 'action_queue'
9
+
10
+ def perform (object_id,rule_id)
11
+ puts "SendAction"
12
+ rule = Rule.find(rule_id)
13
+ object = rule.rule_model.classify.constantize.find(object_id)
14
+ actions = rule.action.where(:active? => true)
15
+ actions.each do |action|
16
+ action_type = action.action_type
17
+ puts "Select Action #{action_type}"
18
+ begin
19
+ JobsActions::Actions.send(action_type,object,rule,action.action_params)
20
+ rescue StandardError => e
21
+ puts e
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.callback(object,rule,action_params)
27
+ puts "callback"
28
+ action_params = JSON.parse(action_params)
29
+ url = action_params["url"]
30
+ attributes = action_params["attr"]
31
+ servidor = Forcast::Utils::Server::Server.new do |config|
32
+ config.dns = url
33
+ config.connect = 1
34
+ config.write = 1
35
+ config.read = 1
36
+ #config.ssl = true
37
+ #config.headers.store("accept","application/json")
38
+ config.before_ping = false
39
+ end
40
+ model_id = object.attributes.slice(*attributes) unless attributes.include?("all")
41
+ json_send = {:data => model_id}
42
+ servidor.conexion(:post,{},"",json_send)
43
+ end
44
+
45
+ def self.telegram(object,rule,action_params)
46
+ puts "telegram"
47
+ end
48
+
49
+ def self.slack(object,rule,action_params)
50
+ puts "slack"
51
+ end
52
+
53
+ def self.email(object, rule, action_params)
54
+ puts "action_params"
55
+ puts action_params
56
+ # attributes = action_params["attributes"]
57
+ # model_id_attributes = object.attributes.slice(*attributes) unless attributes.include?("all")
58
+ # model_id_attributes ||= object.attributes
59
+
60
+ obj_identifier = action_params['attr_id'] ? object.send(action_params['attr_id']) : object.id
61
+ Forcast::Utils::Email::Layout.with(
62
+ to: action_params['owner_email'], cc: action_params['target_email']
63
+ ).default(
64
+ object: object, rule: rule, obj_identifier: obj_identifier
65
+ ).deliver_now
66
+ end
67
+
68
+ def self.notification(action_params); end
69
+
70
+ def self.sms(action_params); end
71
+
72
+ end
73
+ end
@@ -0,0 +1,77 @@
1
+ require 'sidekiq'
2
+ require 'date'
3
+
4
+ include Sidekiq::Worker
5
+
6
+ module JobsPollings
7
+ class AddModelPolling < ActiveJob::Base
8
+ sidekiq_options queue: 'polling_queue'
9
+
10
+ def perform(args={})
11
+ puts "AddModelPolling"
12
+ JobsPollings::ValidateModelPolling.perform_in(args["review_time"].to_i.send("second"),args)
13
+ end
14
+ end
15
+
16
+ class ValidateModelPolling < ActiveJob::Base
17
+ sidekiq_options queue: 'polling_queue'
18
+
19
+ def perform(args={})
20
+ puts "ValidateModelPolling"
21
+ object = c_to_m(args["polling_model"]).find(args["polling_model_id"].to_i)
22
+ #Se podria obtener lista desde el cache
23
+ pollings = object.currents_pollings
24
+ puts "Pollings: #{pollings.size}"
25
+ return if pollings.size == 0
26
+ pollings.each do |polling|
27
+ next unless polling.validate_duration_time
28
+ next unless polling.validate_execute_time
29
+ begin
30
+ rule = polling.rule
31
+ puts "polling Validate Rule #{rule.id}"
32
+ validate_rule(object,rule,polling)
33
+ rescue Exception => e
34
+ puts "Somethings where wrong: "+e.to_s
35
+ end
36
+ end
37
+ review_time = define_review_time(pollings.pluck("review_time"))
38
+ puts review_time
39
+ args = {
40
+ :polling_model => args["polling_model"],
41
+ :polling_model_id => args["polling_model_id"],
42
+ :review_time => review_time,
43
+ :pollings => pollings.size.to_s,
44
+ :created_at => args["created_at"],
45
+ :last_trigger_at => Time.now.strftime("%m/%d/%Y %H:%M"),
46
+ }
47
+ JobsPollings::ValidateModelPolling.perform_in(review_time.to_i.send(:second),args)
48
+ end
49
+
50
+ def define_review_time(pollings_times)
51
+ puts "Shorter Review Time"
52
+ min = pollings_times.min
53
+ min ||= 10
54
+ return min
55
+ end
56
+
57
+ def validate_rule(object,rule,polling)
58
+ #Tipos de regla:= Logicas, Cambio
59
+ #Validar reglas si estan activas
60
+ #return unless rule.active?
61
+ validation = rule.validate_logic(object)
62
+ if validation
63
+ puts "Rule Fulfilled"
64
+ rule_id = rule.id
65
+ JobsActions::Actions.perform_async(object.id,rule_id) if polling.validate_send_time
66
+ else
67
+ puts "Rule Not Met"
68
+ end
69
+ end
70
+
71
+ def c_to_m(model)
72
+ return model.classify.constantize
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -0,0 +1,54 @@
1
+ require 'sidekiq'
2
+ require 'date'
3
+
4
+ include Sidekiq::Worker
5
+
6
+ module JobsWebhooks
7
+
8
+ class ValidateModelWebhook < ActiveJob::Base
9
+ sidekiq_options queue: 'webhook_queue'
10
+ def perform(webhook_model:, webhook_model_id:, changed_attrs_json:, created_at:)
11
+ changed_attrs = JSON.parse(changed_attrs_json)
12
+ puts 'ValidateModelWebhook'
13
+ object = c_to_m(webhook_model).find(webhook_model_id.to_i)
14
+ # Se podria obtener lista desde el cache
15
+ webhooks = triggered_webhooks(object: object, changed_attrs: changed_attrs.keys)
16
+ puts "Webhooks: #{webhooks.size}"
17
+ return if webhooks.empty?
18
+
19
+ webhooks.each do |webhook|
20
+ next unless webhook.validate_duration_time
21
+
22
+ begin
23
+ rule = webhook.rule
24
+ puts "Webhook Validate Rule #{rule.id}"
25
+ validate_rule(object, rule, webhook)
26
+ rescue Exception => e
27
+ puts 'Somethings where wrong: ' + e.to_s
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def validate_rule(object, rule, webhook)
35
+ validation = rule.validate_logic(object)
36
+ if validation
37
+ puts 'Rule Fulfilled'
38
+ rule_id = rule.id
39
+ JobsActions::Actions.perform_async(object.id, rule_id) if webhook.validate_send_time
40
+ else
41
+ puts 'Rule Not Met'
42
+ end
43
+ end
44
+
45
+ def c_to_m(model)
46
+ model.classify.constantize
47
+ end
48
+
49
+ def triggered_webhooks(object:, changed_attrs:)
50
+ Webhook.includes(:rule).references(:rule)
51
+ .merge(Rule.actives.for_attributes(changed_attrs).for_object_and_class(object))
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,44 @@
1
+ $files = Dir["#{Rails.root}/db/migrate/tables/*.rb"]
2
+ $files.each do |file|
3
+ require file
4
+ end
5
+
6
+ class MigracionGeneral < ActiveRecord::Migration[5.1]
7
+
8
+ def self.tables
9
+ general_tables
10
+ end
11
+
12
+ def self.general_tables
13
+ @tables = []
14
+ $files.each do |file|
15
+ require file
16
+ table = "#{file.split("/").last.gsub('.rb','').titleize.delete(' ')}"
17
+ next if table == 'Base'
18
+ @tables.push(eval("Tables::#{table}"))
19
+ end
20
+ return @tables
21
+ end
22
+
23
+ def up
24
+ run_migrations
25
+ end
26
+
27
+ def down
28
+ raise ActiveRecord::IrreversibleMigration, 'Error'
29
+ end
30
+
31
+ private
32
+
33
+ def run_migrations
34
+ create_tables
35
+ end
36
+
37
+ def create_tables
38
+ self.class.tables.each do |table|
39
+ table.create(self)
40
+ end
41
+ end
42
+
43
+
44
+ end
@@ -0,0 +1,61 @@
1
+ # This migration creates the `versions` table, the only schema PT requires.
2
+ # All other migrations PT provides are optional.
3
+ class CreateVersions < ActiveRecord::Migration[5.1]
4
+
5
+ # The largest text column available in all supported RDBMS is
6
+ # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
7
+ # so that MySQL will use `longtext` instead of `text`. Otherwise,
8
+ # when serializing very large objects, `text` might not be big enough.
9
+ TEXT_BYTES = 1_073_741_823
10
+
11
+ def change
12
+ create_table :versions do |t|
13
+ t.string :item_type, {:null=>false}
14
+ t.integer :item_id, null: false
15
+ t.string :event, null: false
16
+ t.string :whodunnit
17
+ t.text :object, limit: TEXT_BYTES
18
+
19
+ # Known issue in MySQL: fractional second precision
20
+ # -------------------------------------------------
21
+ #
22
+ # MySQL timestamp columns do not support fractional seconds unless
23
+ # defined with "fractional seconds precision". MySQL users should manually
24
+ # add fractional seconds precision to this migration, specifically, to
25
+ # the `created_at` column.
26
+ # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
27
+ #
28
+ # MySQL users should also upgrade to at least rails 4.2, which is the first
29
+ # version of ActiveRecord with support for fractional seconds in MySQL.
30
+ # (https://github.com/rails/rails/pull/14359)
31
+ #
32
+ t.datetime :created_at
33
+ end
34
+ add_index :versions, %i(item_type item_id)
35
+ end
36
+ end
37
+
38
+ require_relative 'base'
39
+
40
+ class Tables::Webhooks < Tables::Base
41
+
42
+ def self.table(migration)
43
+ create_table migration do |t|
44
+ t.string :webhook_model
45
+ t.integer :webhook_model_id
46
+ t.integer :send_time
47
+ t.integer :duration_time
48
+ t.boolean :active?
49
+ t.boolean :forever_true?
50
+ t.datetime :last_execution
51
+ t.datetime :last_review_send
52
+ t.datetime :last_send
53
+ t.boolean :execute?
54
+ t.boolean :send?
55
+ t.bigint :rule_id
56
+ t.index :rule_id, name: 'index_rule_webhook_id'
57
+ t.timestamps
58
+ end
59
+ end
60
+ end
61
+
@@ -0,0 +1,15 @@
1
+ require_relative 'base'
2
+
3
+ class Tables::ActionLogs < Tables::Base
4
+
5
+ def self.table(migration)
6
+ create_table migration do |t|
7
+ t.string :action_type
8
+ t.text :action_params
9
+ t.text :action_result
10
+ t.bigint :action_id
11
+ t.index :action_id, name: 'index_action_action_log_id'
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'base'
2
+
3
+ class Tables::Actions < Tables::Base
4
+
5
+ def self.table(migration)
6
+ create_table migration do |t|
7
+ t.string :action_type
8
+ t.json :action_params
9
+ t.boolean :active?
10
+ t.bigint :rule_id
11
+ t.index :rule_id, name: 'index_rule_action_id'
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'base'
2
+
3
+ class Tables::Pollings < Tables::Base
4
+
5
+ def self.table(migration)
6
+ create_table migration do |t|
7
+ t.string :polling_model
8
+ t.integer :polling_model_id
9
+ t.integer :review_time
10
+ t.integer :send_time
11
+ t.integer :duration_time
12
+ t.boolean :active?
13
+ t.datetime :last_execution
14
+ t.datetime :last_review_send
15
+ t.datetime :last_send
16
+ t.boolean :execute?
17
+ t.boolean :send?
18
+ t.boolean :class_polling?
19
+ t.bigint :rule_id
20
+ t.index :rule_id, name: 'index_rule_polling_id'
21
+
22
+ t.timestamps
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,22 @@
1
+ require_relative 'base'
2
+
3
+ class Tables::RuleLogs < Tables::Base
4
+
5
+ def self.table(migration)
6
+ create_table migration do |t|
7
+ t.string :name
8
+ t.string :rule_model
9
+ t.integer :rule_model_id
10
+ t.string :attr_comparable
11
+ t.string :rule
12
+ t.string :rule_type
13
+ t.string :rule_class
14
+ t.string :value
15
+ t.text :actions
16
+ t.bigint :rule_id
17
+ t.index :rule_id, name: 'index_rule_rule_log_id'
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,27 @@
1
+ require_relative 'base'
2
+
3
+ class Tables::Rules < Tables::Base
4
+
5
+ def self.table(migration)
6
+ create_table migration do |t|
7
+ t.string :name
8
+ t.string :rule_model
9
+ t.integer :rule_model_id
10
+ t.string :value_s
11
+ t.integer :value_i
12
+ t.decimal :value_d
13
+ t.boolean :value_b
14
+ t.datetime :value_t
15
+ t.string :rule
16
+ t.string :rule_type
17
+ t.string :rule_class
18
+ t.string :combine_type
19
+ t.string :attr_comparable
20
+ t.string :last_value_attr_comparable
21
+ t.boolean :class_rule?
22
+ t.boolean :active?
23
+ t.timestamps
24
+ end
25
+ end
26
+ end
27
+