diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-28 13:44:21 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-28 13:44:21 +0100 |
commit | 600574759573e48da9f5f82d4ff8a863b6830c95 (patch) | |
tree | 1bb5dc36fb28c96ad9be9a2357d380c2c24ee31e | |
parent | fd95d2c2fcc50418cdb23f34b21bcfe04d9cc1de (diff) |
Checks if the table already exists (could be generated by FreeSWITCH). #144
-rw-r--r-- | db/migrate/20130128121800_create_sip_registrations.rb | 86 | ||||
-rw-r--r-- | db/schema.rb | 46 |
2 files changed, 89 insertions, 43 deletions
diff --git a/db/migrate/20130128121800_create_sip_registrations.rb b/db/migrate/20130128121800_create_sip_registrations.rb index 4157b84..473418e 100644 --- a/db/migrate/20130128121800_create_sip_registrations.rb +++ b/db/migrate/20130128121800_create_sip_registrations.rb @@ -1,48 +1,50 @@ class CreateSipRegistrations < ActiveRecord::Migration def self.up - create_table :sip_registrations, :id => false do |t| - t.string :call_id, :limit => '255' - t.string :sip_user, :limit => '255' - t.string :sip_host, :limit => '255' - t.string :presence_hosts, :limit => '255' - t.string :contact, :limit => '1024' - t.string :status, :limit => '255' - t.string :rpid, :limit => '255' - t.integer :expires - t.string :user_agent, :limit => '255' - t.string :server_user, :limit => '255' - t.string :server_host, :limit => '255' - t.string :profile_name, :limit => '255' - t.string :hostname, :limit => '255' - t.string :network_ip, :limit => '255' - t.string :network_port, :limit => '6' - t.string :sip_username, :limit => '255' - t.string :sip_realm, :limit => '255' - t.string :mwi_user, :limit => '255' - t.string :mwi_host, :limit => '255' - t.string :orig_server_host, :limit => '255' - t.string :orig_hostname, :limit => '255' - t.string :sub_host, :limit => '255' - end + if !(ActiveRecord::Base.connection.table_exists? 'sip_registrations') + create_table :sip_registrations, :id => false do |t| + t.string :call_id, :limit => '255' + t.string :sip_user, :limit => '255' + t.string :sip_host, :limit => '255' + t.string :presence_hosts, :limit => '255' + t.string :contact, :limit => '1024' + t.string :status, :limit => '255' + t.string :rpid, :limit => '255' + t.integer :expires + t.string :user_agent, :limit => '255' + t.string :server_user, :limit => '255' + t.string :server_host, :limit => '255' + t.string :profile_name, :limit => '255' + t.string :hostname, :limit => '255' + t.string :network_ip, :limit => '255' + t.string :network_port, :limit => '6' + t.string :sip_username, :limit => '255' + t.string :sip_realm, :limit => '255' + t.string :mwi_user, :limit => '255' + t.string :mwi_host, :limit => '255' + t.string :orig_server_host, :limit => '255' + t.string :orig_hostname, :limit => '255' + t.string :sub_host, :limit => '255' + end - add_index :sip_registrations, [ :call_id ], :name => 'sr_call_id' - add_index :sip_registrations, [ :sip_user ], :name => 'sr_sip_user' - add_index :sip_registrations, [ :sip_host ], :name => 'sr_sip_host' - add_index :sip_registrations, [ :sub_host ], :name => 'sr_sub_host' - add_index :sip_registrations, [ :mwi_user ], :name => 'sr_mwi_user' - add_index :sip_registrations, [ :mwi_host ], :name => 'sr_mwi_host' - add_index :sip_registrations, [ :profile_name ], :name => 'sr_profile_name' - add_index :sip_registrations, [ :presence_hosts ], :name => 'sr_presence_hosts' - add_index :sip_registrations, [ :contact ], :name => 'sr_contact' - add_index :sip_registrations, [ :expires ], :name => 'sr_expires' - add_index :sip_registrations, [ :hostname ], :name => 'sr_hostname' - add_index :sip_registrations, [ :status ], :name => 'sr_status' - add_index :sip_registrations, [ :network_ip ], :name => 'sr_network_ip' - add_index :sip_registrations, [ :network_port ], :name => 'sr_network_port' - add_index :sip_registrations, [ :sip_username ], :name => 'sr_sip_username' - add_index :sip_registrations, [ :sip_realm ], :name => 'sr_sip_realm' - add_index :sip_registrations, [ :orig_server_host ], :name => 'sr_orig_server_host' - add_index :sip_registrations, [ :orig_hostname ], :name => 'sr_orig_hostname' + add_index :sip_registrations, [ :call_id ], :name => 'sr_call_id' + add_index :sip_registrations, [ :sip_user ], :name => 'sr_sip_user' + add_index :sip_registrations, [ :sip_host ], :name => 'sr_sip_host' + add_index :sip_registrations, [ :sub_host ], :name => 'sr_sub_host' + add_index :sip_registrations, [ :mwi_user ], :name => 'sr_mwi_user' + add_index :sip_registrations, [ :mwi_host ], :name => 'sr_mwi_host' + add_index :sip_registrations, [ :profile_name ], :name => 'sr_profile_name' + add_index :sip_registrations, [ :presence_hosts ], :name => 'sr_presence_hosts' + add_index :sip_registrations, [ :contact ], :name => 'sr_contact' + add_index :sip_registrations, [ :expires ], :name => 'sr_expires' + add_index :sip_registrations, [ :hostname ], :name => 'sr_hostname' + add_index :sip_registrations, [ :status ], :name => 'sr_status' + add_index :sip_registrations, [ :network_ip ], :name => 'sr_network_ip' + add_index :sip_registrations, [ :network_port ], :name => 'sr_network_port' + add_index :sip_registrations, [ :sip_username ], :name => 'sr_sip_username' + add_index :sip_registrations, [ :sip_realm ], :name => 'sr_sip_realm' + add_index :sip_registrations, [ :orig_server_host ], :name => 'sr_orig_server_host' + add_index :sip_registrations, [ :orig_hostname ], :name => 'sr_orig_hostname' + end end def self.down diff --git a/db/schema.rb b/db/schema.rb index 73a1454..7bae5fd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130124175109) do +ActiveRecord::Schema.define(:version => 20130128121800) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" @@ -876,6 +876,50 @@ ActiveRecord::Schema.define(:version => 20130124175109) do t.datetime "updated_at", :null => false end + create_table "sip_registrations", :id => false, :force => true do |t| + t.string "call_id" + t.string "sip_user" + t.string "sip_host" + t.string "presence_hosts" + t.string "contact", :limit => 1024 + t.string "status" + t.string "rpid" + t.integer "expires" + t.string "user_agent" + t.string "server_user" + t.string "server_host" + t.string "profile_name" + t.string "hostname" + t.string "network_ip" + t.string "network_port", :limit => 6 + t.string "sip_username" + t.string "sip_realm" + t.string "mwi_user" + t.string "mwi_host" + t.string "orig_server_host" + t.string "orig_hostname" + t.string "sub_host" + end + + add_index "sip_registrations", ["call_id"], :name => "sr_call_id" + add_index "sip_registrations", ["contact"], :name => "sr_contact" + add_index "sip_registrations", ["expires"], :name => "sr_expires" + add_index "sip_registrations", ["hostname"], :name => "sr_hostname" + add_index "sip_registrations", ["mwi_host"], :name => "sr_mwi_host" + add_index "sip_registrations", ["mwi_user"], :name => "sr_mwi_user" + add_index "sip_registrations", ["network_ip"], :name => "sr_network_ip" + add_index "sip_registrations", ["network_port"], :name => "sr_network_port" + add_index "sip_registrations", ["orig_hostname"], :name => "sr_orig_hostname" + add_index "sip_registrations", ["orig_server_host"], :name => "sr_orig_server_host" + add_index "sip_registrations", ["presence_hosts"], :name => "sr_presence_hosts" + add_index "sip_registrations", ["profile_name"], :name => "sr_profile_name" + add_index "sip_registrations", ["sip_host"], :name => "sr_sip_host" + add_index "sip_registrations", ["sip_realm"], :name => "sr_sip_realm" + add_index "sip_registrations", ["sip_user"], :name => "sr_sip_user" + add_index "sip_registrations", ["sip_username"], :name => "sr_sip_username" + add_index "sip_registrations", ["status"], :name => "sr_status" + add_index "sip_registrations", ["sub_host"], :name => "sr_sub_host" + create_table "softkey_functions", :force => true do |t| t.string "name" t.datetime "created_at", :null => false |