Randomness

Asterisk RealTime – Ruby on Rails Migrations & Models

Posted on: August 16, 2007

Pulled from voipinfo.org

Using Ruby on Rails Migrations the below will support any combination of database that ActiveRecord and Asterisk Realtime Architecture support, including of course MySQL and Postgres.

Ruby on Rails Models are then provided to be dropped into any Ruby on Rails application that requires the ability to configure Asterisk via the Asterisk Realtime Architecture.

ActiveRecord::Schema.define() do
#Use the same table for IAX2 and SIP configuration
create_table "devices", :force => true do |t|
t.column :name, :string, :limit => 80
t.column :accountcode, :string, :limit => 20
t.column :amaflags, :string, :limit => 13
t.column :callgroup, :string, :limit => 10
t.column :callerid, :string, :limit => 80
t.column :canreinvite, :string, :limit => 3, :default => 'yes'
t.column :context, :string, :limit => 80
t.column :defaultip, :string, :limit => 15
t.column :dtmfmode, :string, :limit => 7
t.column :fromuser, :string, :limit => 80
t.column :fromdomain, :string, :limit => 80
t.column :fullcontact, :string, :limit => 80
t.column :host, :string, :limit => 31, :default => 'dynamic'
t.column :insecure, :string, :limit => 4
t.column :language, :string, :limit => 2
t.column :mailbox, :string, :limit => 50
t.column :md5secret, :string, :limit => 80
t.column :nat, :string, :limit => 5, :default => 'no'
t.column :deny, :string, :limit => 95
t.column :permit, :string, :limit => 95
t.column :mask, :string, :limit => 95
t.column :pickupgroup, :string, :limit => 10
t.column :port, :string, :limit => 5, :default => ''
t.column :qualify, :string, :limit => 3
t.column :restrictcid, :string, :limit => 1
t.column :rtptimeout, :string, :limit => 3
t.column :rtpholdtimeout, :string, :limit => 3
t.column :secret, :string, :limit => 80
t.column :type, :string, :limit => 6, :default => 'friend'
t.column :username, :string, :limit => 80
t.column :disallow, :string, :limit => 100
t.column :allow, :string, :limit => 100
t.column :musiconhold, :string, :limit => 100
t.column :regseconds, :integer, :limit => 11, :default => 0
t.column :ipaddr, :string, :limit => 15, :default => '0'
t.column :regexten, :string, :limit => 80
t.column :cancallforward, :string, :limit => 3, :default => 'yes'
t.column :setvar, :string, :limit => 100
#Additional fields for IAX2
t.column :dbsecret, :string, :limit => 100
t.column :inkeys, :string, :limit => 100
t.column :outkey, :string, :limit => 100
t.column :auth, :string, :limit => 100
end

#Asterisk extensions table
create_table "extensions", :force => true do |t|
t.column :context, :string, :limit => 20, :null => false
t.column :exten, :string, :limit => 20, :null => false
t.column :priority, :integer, :limit => 4, :default => 0
t.column :app, :string, :limit => 20, :null => false
t.column :appdata, :string, :limit => 128, :null => false
end

#Asterisk queues table
create_table "callqueues", :force => true do |t|
t.column :name, :string, :limit => 128
t.column :musiconhold, :string, :limit => 128
t.column :announce, :string, :limit => 128
t.column :timeout, :integer, :limit => 11
t.column :monitor_join, :boolean
t.column :monitor_format, :string, :limit => 128
t.column :queue_youarenext, :string, :limit => 128
t.column :queue_thereare, :string, :limit => 128
t.column :queue_callswaiting, :string, :limit => 128
t.column :queue_holdtime, :string, :limit => 128
t.column :queue_minutes, :string, :limit => 128
t.column :queue_seconds, :string, :limit => 128
t.column :queue_lessthan, :string, :limit => 128
t.column :queue_thankyou, :string, :limit => 128
t.column :queue_reporthold, :string, :limit => 128
t.column :announce_frequency, :integer, :limit => 11
t.column :announce_round_seconds, :integer, :limit => 11
t.column :announce_holdtime, :string, :limit => 128
t.column :retry, :integer, :limit => 11
t.column :wrapuptime, :integer, :limit => 11
t.column :maxlen, :integer, :limit => 11
t.column :servicelevel, :integer, :limit => 11
t.column :strategy, :string, :limit => 128
t.column :joinempty, :string, :limit => 128
t.column :leavewhenempty, :string, :limit => 128
t.column :eventmemberstatus, :boolean
t.column :eventwhencalled, :boolean
t.column :reportholdtime, :boolean
t.column :memberdelay, :integer, :limit => 11
t.column :weight, :integer, :limit => 11
t.column :timeoutrestart, :boolean
end

#Asterisk voicemail extended table
create_table "voicemailboxes", :force => true do |t|
t.column :customer_id, :string, :limit => 11, :null => false
t.column :context, :string, :limit => 50, :default => '0'
t.column :mailbox, :string, :limit => 11, :null => false
t.column :password, :integer, :limit => 5, :default => '0'
t.column :fullname, :string, :limit => 150, :null => false
t.column :email, :string, :limit => 50, :null => false
t.column :pager, :string, :limit => 50, :default => ''
t.column :tz, :string, :limit => 10, :default => 'central'
t.column :attach, :string, :limit => 4, :default => 'yes'
t.column :saycid, :string, :limit => 4, :default => 'yes'
t.column :dialout, :string, :limit => 10, :default => ''
t.column :callback, :string, :limit => 10, :default => ''
t.column :review, :string, :limit => 4, :default => 'no'
t.column :operator, :string, :limit => 4, :default => 'no'
t.column :envelope, :string, :limit => 4, :default => 'no'
t.column :sayduration, :string, :limit => 4, :default => 'no'
t.column :saydurationm, :integer, :limit => 4, :default => 1
t.column :sendvoicemail, :string, :limit => 4, :default => 'no'
t.column :delete, :string, :limit => 4, :default => 'no'
t.column :nextaftercmd, :integer, :limit => 4, :default => 'yes'
t.column :forcename, :integer, :limit => 4, :default => 'no'
t.column :forcegreetings, :integer, :limit => 4, :default => 'no'
t.column :hidefromdir, :string, :limit => 4, :default => 'yes'
t.column :stamp, :timestamp
end

#Asterisk voicemail extended table
create_table "voicemailmessages", :force => true do |t|
t.column :msgnum, :integer, :limit => 11, :default => 0
t.column :dir, :string, :limit => 80, :default => ''
t.column :context, :string, :limit => 80, :default => ''
t.column :macrocontext, :string, :limit => 80, :default => ''
t.column :callerid, :string, :limit => 40, :default => ''
t.column :origtime, :string, :limit => 40, :default => ''
t.column :duration, :string, :limit => 20, :default => ''
t.column :mailboxuser, :string, :limit => 80, :default => ''
t.column :mailboxcontext, :string, :limit => 80, :default => ''
t.column :recording, :longblob
end

end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: