-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging_schema.rb
46 lines (37 loc) · 1.04 KB
/
logging_schema.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
#!/usr/bin/env ruby
require 'sequel'
require 'yaml'
basedir = File.dirname(__FILE__)
config = YAML.load_file("#{basedir}/config.yml")
dbname = config['logging_url'].split('/').last
_DB0 = Sequel.connect config['logging_url']
_DB0.run "drop database if exists #{dbname};"
_DB0.run "create database #{dbname};"
_DB0.run "use #{dbname};"
require_relative './logging_init'
LOGGING_DB.create_table! :s3_log_files do
primary_key :id
String :filename, {:null => false, :unique => true}
index :filename, :unique=>true
end
# FIXME add appropriate indexes
LOGGING_DB.create_table! :log_entries do
primary_key :id
DateTime :timestamp
String :remote_ip
String :url
String :request_uri
String :http_status
String :s3_error_code
TrueClass :is_s3, {:null => false}
Integer :bytes_sent
Integer :object_size
Integer :total_time
Integer :turn_around_time
String :referrer
String :user_agent
String :s3_version_id
Integer :s3_log_file_id
Integer :id_fetched
Integer :resource_fetched
end