20121228171549_initial_schema.rb - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
HTML git clone git://jay.scot/warvox
DIR Log
DIR Files
DIR Refs
DIR README
---
20121228171549_initial_schema.rb (6474B)
---
1 # class InitialSchema < ActiveRecord::Migration
2 class InitialSchema < ActiveRecord::Migration[5.0]
3 def up
4 # Require the intarray extension
5 execute("CREATE EXTENSION IF NOT EXISTS intarray")
6
7 create_table :settings do |t|
8 t.string :var, null: false
9 t.text :value, null: true
10 t.integer :thing_id, null: true
11 t.string :thing_type, limit: 30, null: true
12 t.timestamps null: false
13 end
14
15 add_index :settings, [ :thing_type, :thing_id, :var ], unique: true
16
17 create_table 'users' do |t|
18 t.string :login, null: false # optional, you can use email instead, or both
19 t.string :email, null: true # optional, you can use login instead, or both
20 t.string :crypted_password, null: false # optional, see below
21 t.string :password_salt, null: false # optional, but highly recommended
22 t.string :persistence_token, null: false # required
23 t.string :single_access_token, null: false # optional, see Authlogic::Session::Params
24 t.string :perishable_token, null: false # optional, see Authlogic::Session::Perishability
25
26 # Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
27 t.integer :login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
28 t.integer :failed_login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
29 t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
30 t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
31 t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
32 t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
33 t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
34
35 t.timestamps null: false
36 t.boolean "enabled", default: true
37 t.boolean "admin", default: true
38 end
39
40 create_table 'projects' do |t|
41 t.timestamps null: false
42 t.text "name", null: false
43 t.text "description"
44 t.text "included"
45 t.text "excluded"
46 t.string "created_by"
47 end
48
49 create_table "jobs" do |t|
50 t.timestamps null: false
51 t.integer "project_id", null: false
52 t.string "locked_by"
53 t.timestamp "locked_at"
54 t.timestamp "started_at"
55 t.timestamp "completed_at"
56 t.string "created_by"
57 t.string "task", null: false
58 t.binary "args"
59 t.string "status"
60 t.text "error"
61 t.integer "progress", default: 0
62 end
63
64 create_table "lines" do |t|
65 t.timestamps null: false
66 t.text "number", null: false
67 t.integer "project_id", null: false
68 t.text "line_type"
69 t.text "notes"
70 end
71
72 create_table "line_attributes" do |t|
73 t.timestamps null: false
74 t.integer "line_id", null: false
75 t.integer "project_id", null: false
76 t.text "name", null: false
77 t.binary "value", null: false
78 t.string "content_type", default: "text"
79 end
80
81 create_table "calls" do |t|
82 # Created by the dialer job
83 t.timestamps null: false
84 t.text "number", null: false
85 t.integer "project_id", null: false
86 t.integer "job_id", null: false
87 t.integer "provider_id", null: false
88 t.boolean "answered"
89 t.boolean "busy"
90 t.text "error"
91 t.integer "audio_length"
92 t.integer "ring_length"
93 t.text "caller_id"
94
95 # Generated by the analysis job
96 t.integer "analysis_job_id"
97 t.timestamp "analysis_started_at"
98 t.timestamp "analysis_completed_at"
99 t.float "peak_freq"
100 t.text "peak_freq_data"
101 t.text "line_type"
102 t.integer "fprint", array: true
103 end
104
105 create_table "call_media" do |t|
106 t.integer "call_id", null: false
107 t.integer "project_id", null: false
108 t.binary "audio"
109 t.binary "mp3"
110 t.binary "png_big"
111 t.binary "png_big_dots"
112 t.binary "png_big_freq"
113 t.binary "png_sig"
114 t.binary "png_sig_freq"
115 end
116
117 create_table "signatures" do |t|
118 t.timestamps null: false
119 t.text "name", null: false
120 t.string "source"
121 t.text "description"
122 t.string "category"
123 t.string "line_type"
124 t.integer "risk"
125 end
126
127 create_table "signature_fp" do |t|
128 t.integer "signature_id", null: false
129 t.integer "fprint", array: true
130 end
131
132 create_table "providers" do |t|
133 t.timestamps null: false
134 t.text "name", null: false
135 t.text "host", null: false
136 t.integer "port", null: false
137 t.text "user"
138 t.text "pass"
139 t.integer "lines", null: false, default: 1
140 t.boolean "enabled", default: true
141 end
142
143 add_index :jobs, :project_id
144 add_index :lines, :number
145 add_index :lines, :project_id
146 add_index :line_attributes, :line_id
147 add_index :line_attributes, :project_id
148 add_index :calls, :number
149 add_index :calls, :job_id
150 add_index :calls, :provider_id
151 add_index :call_media, :call_id
152 add_index :call_media, :project_id
153 add_index :signature_fp, :signature_id
154 end
155
156 def down
157 remove_index :jobs, :project_id
158 remove_index :lines, :number
159 remove_index :lines, :project_id
160 remove_index :line_attributes, :line_id
161 remove_index :line_attributes, :project_id
162 remove_index :calls, :number
163 remove_index :calls, :job_id
164 remove_index :calls, :provider_id
165 remove_index :call_media, :call_id
166 remove_index :call_media, :project_id
167 remove_index :signature_fp, :signature_id
168
169 drop_table "providers"
170 drop_table "signature_fp"
171 drop_table "signatures"
172 drop_table "call_media"
173 drop_table "calls"
174 drop_table "line_attributes"
175 drop_table "lines"
176 drop_table "jobs"
177 drop_table "projects"
178 drop_table "users"
179 drop_table "settings"
180 end
181 end