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
|
# File 'lib/behavior_lens/database.rb', line 15
def self.setup
ActiveRecord::Schema.define do
connection = ActiveRecord::Base.connection
unless connection.data_source_exists?('clicks')
create_table :clicks do |t|
t.string :link, null: false
t.integer :count, default: 1
t.timestamps
end
end
unless connection.data_source_exists?('sessions')
create_table :sessions do |t|
t.string :user_id, null: false
t.datetime :start_time
t.datetime :end_time
t.timestamps
end
end
unless connection.data_source_exists?('events')
create_table :events do |t|
t.string :name, null: false
t.json :metadata
t.timestamps
end
end
end
end
|