Class: Vanity::Adapters::ActiveRecordAdapter::VanityRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Vanity::Adapters::ActiveRecordAdapter::VanityRecord
- Defined in:
- lib/vanity/adapters/active_record_adapter.rb
Overview
Base model, stores connection and defines schema
Direct Known Subclasses
VanityConversion, VanityExperiment, VanityMetric, VanityMetricValue, VanityParticipant, VanitySchema
Class Method Summary collapse
Class Method Details
.define_schema ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vanity/adapters/active_record_adapter.rb', line 15 def self.define_schema # Create a schema table to store the schema version unless connection.tables.include?('vanity_schema') connection.create_table :vanity_schema do |t| t.integer :version end end # Migrate unless VanitySchema.find_by_version(1) connection.create_table :vanity_metrics do |t| t.string :metric_id t.datetime :updated_at end connection.add_index :vanity_metrics, [:metric_id] connection.create_table :vanity_metric_values do |t| t.integer :vanity_metric_id t.integer :index t.integer :value t.string :date end connection.add_index :vanity_metric_values, [:vanity_metric_id] connection.create_table :vanity_experiments do |t| t.string :experiment_id t.integer :outcome t.datetime :created_at t.datetime :completed_at end connection.add_index :vanity_experiments, [:experiment_id] connection.create_table :vanity_conversions do |t| t.integer :vanity_experiment_id t.integer :alternative t.integer :conversions end connection.add_index :vanity_conversions, [:vanity_experiment_id, :alternative] connection.create_table :vanity_participants do |t| t.string :experiment_id t.string :identity t.integer :shown t.integer :seen t.integer :converted end connection.add_index :vanity_participants, [:experiment_id] connection.add_index :vanity_participants, [:experiment_id, :identity] connection.add_index :vanity_participants, [:experiment_id, :shown] connection.add_index :vanity_participants, [:experiment_id, :seen] connection.add_index :vanity_participants, [:experiment_id, :converted] VanitySchema.create(:version => 1) end end |