Initial Commit
Co-authored-by: Subin <subinthattaparambil@gmail.com> Co-authored-by: Manoj <manojmj92@gmail.com> Co-authored-by: Nithin <webofnithin@gmail.com>
This commit is contained in:
9
db/migrate/20161022055031_create_accounts.rb
Normal file
9
db/migrate/20161022055031_create_accounts.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class CreateAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :accounts do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/migrate/20161022060602_create_inboxes.rb
Normal file
10
db/migrate/20161022060602_create_inboxes.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateInboxes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :inboxes do |t|
|
||||
t.integer :channel_id
|
||||
t.integer :account_id
|
||||
t.string :name
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/migrate/20161022061641_create_contacts.rb
Normal file
13
db/migrate/20161022061641_create_contacts.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateContacts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :contacts do |t|
|
||||
t.string :name
|
||||
t.string :email
|
||||
t.string :phone_number
|
||||
t.integer :channel_id
|
||||
t.integer :account_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/migrate/20161022062829_create_conversations.rb
Normal file
13
db/migrate/20161022062829_create_conversations.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateConversations < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :conversations do |t|
|
||||
t.integer :account_id
|
||||
t.integer :channel_id
|
||||
t.integer :inbox_id
|
||||
t.integer :status
|
||||
t.integer :assignee_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/migrate/20161022072124_create_messages.rb
Normal file
13
db/migrate/20161022072124_create_messages.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateMessages < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :messages do |t|
|
||||
t.text :content
|
||||
t.integer :account_id
|
||||
t.integer :channel_id
|
||||
t.integer :inbox_id
|
||||
t.integer :conversation_id
|
||||
t.integer :type
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161022073137_add_sender_to_conversation.rb
Normal file
5
db/migrate/20161022073137_add_sender_to_conversation.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSenderToConversation < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :conversations, :sender_id, :integer
|
||||
end
|
||||
end
|
||||
10
db/migrate/20161022080042_create_inbox_members.rb
Normal file
10
db/migrate/20161022080042_create_inbox_members.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateInboxMembers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :inbox_members do |t|
|
||||
t.integer :user_id
|
||||
t.integer :inbox_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161025063304_dropchannels.rb
Normal file
5
db/migrate/20161025063304_dropchannels.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Dropchannels < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
# drop_table :channels
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161025063510_addchanneltype.rb
Normal file
5
db/migrate/20161025063510_addchanneltype.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Addchanneltype < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :inboxes, :channel_type, :string
|
||||
end
|
||||
end
|
||||
13
db/migrate/20161025064031_create_facebook_pages.rb
Normal file
13
db/migrate/20161025064031_create_facebook_pages.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateFacebookPages < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :facebook_pages do |t|
|
||||
t.string :name
|
||||
t.string :page_id, null: false
|
||||
t.string :user_access_token, null: false
|
||||
t.string :page_access_token, null: false
|
||||
t.integer :account_id, null: false
|
||||
t.integer :inbox_id, null: false
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
6
db/migrate/20161025070152_removechannelsfrommodels.rb
Normal file
6
db/migrate/20161025070152_removechannelsfrommodels.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Removechannelsfrommodels < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_column :contacts, :channel_id
|
||||
add_column :contacts, :inbox_id, :integer
|
||||
end
|
||||
end
|
||||
6
db/migrate/20161025070645_remchannel.rb
Normal file
6
db/migrate/20161025070645_remchannel.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Remchannel < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_column :conversations, :channel_id
|
||||
remove_column :messages, :channel_id
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161029151508_change_type_to_message_type.rb
Normal file
5
db/migrate/20161029151508_change_type_to_message_type.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ChangeTypeToMessageType < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
rename_column :messages, :type, :message_type
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161110102609_removeinboxid.rb
Normal file
5
db/migrate/20161110102609_removeinboxid.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Removeinboxid < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_column :facebook_pages, :inbox_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class ChangeIntegerLimitOfSenderId < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :conversations, :sender_id, :integer, limit: 8
|
||||
end
|
||||
end
|
||||
10
db/migrate/20161114101802_create_telegram_bots.rb
Normal file
10
db/migrate/20161114101802_create_telegram_bots.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateTelegramBots < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :telegram_bots do |t|
|
||||
t.string :name
|
||||
t.string :auth_key
|
||||
t.integer :account_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
54
db/migrate/20161123131628_devise_token_auth_create_users.rb
Normal file
54
db/migrate/20161123131628_devise_token_auth_create_users.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table(:users) do |t|
|
||||
## Required
|
||||
t.string :provider, :null => false, :default => "email"
|
||||
t.string :uid, :null => false, :default => ""
|
||||
|
||||
## Database authenticatable
|
||||
t.string :encrypted_password, :null => false, :default => ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, :default => 0, :null => false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.string :current_sign_in_ip
|
||||
t.string :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
t.string :confirmation_token
|
||||
t.datetime :confirmed_at
|
||||
t.datetime :confirmation_sent_at
|
||||
t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
## Lockable
|
||||
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
||||
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||
# t.datetime :locked_at
|
||||
|
||||
## User Info
|
||||
t.string :name
|
||||
t.string :nickname
|
||||
t.string :image
|
||||
t.string :email
|
||||
|
||||
## Tokens
|
||||
t.json :tokens
|
||||
t.integer :account_id, :null => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :users, :email
|
||||
add_index :users, [:uid, :provider], :unique => true
|
||||
add_index :users, :reset_password_token, :unique => true
|
||||
# add_index :users, :confirmation_token, :unique => true
|
||||
# add_index :users, :unlock_token, :unique => true
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170124104836_change_contact_to_bigint.rb
Normal file
5
db/migrate/20170124104836_change_contact_to_bigint.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ChangeContactToBigint < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :contacts, :id , :bigint
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170131132031_addprivatemessages.rb
Normal file
5
db/migrate/20170131132031_addprivatemessages.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Addprivatemessages < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :messages, :private, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 1)
|
||||
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :tags do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :taggings do |t|
|
||||
t.references :tag
|
||||
|
||||
# You should make sure that the column created is
|
||||
# long enough to store the required class names.
|
||||
t.references :taggable, polymorphic: true
|
||||
t.references :tagger, polymorphic: true
|
||||
|
||||
# Limit is created to prevent MySQL error on index
|
||||
# length for MyISAM table type: http://bit.ly/vgW2Ql
|
||||
t.string :context, limit: 128
|
||||
|
||||
t.datetime :created_at
|
||||
end
|
||||
|
||||
add_index :taggings, :tag_id
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :taggings
|
||||
drop_table :tags
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :tags, :name, unique: true
|
||||
|
||||
remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
|
||||
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
add_index :taggings,
|
||||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
||||
unique: true, name: 'taggings_idx'
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :tags, :name
|
||||
|
||||
remove_index :taggings, name: 'taggings_idx'
|
||||
|
||||
add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 3)
|
||||
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :tags, :taggings_count, :integer, default: 0
|
||||
|
||||
ActsAsTaggableOn::Tag.reset_column_information
|
||||
ActsAsTaggableOn::Tag.find_each do |tag|
|
||||
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :tags, :taggings_count
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 4)
|
||||
class AddMissingTaggableIndex < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 5)
|
||||
# This migration is added to circumvent issue #623 and have special characters
|
||||
# work properly
|
||||
class ChangeCollationForTagNames < ActiveRecord::Migration
|
||||
def up
|
||||
if ActsAsTaggableOn::Utils.using_mysql?
|
||||
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 6)
|
||||
class AddMissingIndexes < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :taggings, :tag_id
|
||||
add_index :taggings, :taggable_id
|
||||
add_index :taggings, :taggable_type
|
||||
add_index :taggings, :tagger_id
|
||||
add_index :taggings, :context
|
||||
|
||||
add_index :taggings, [:tagger_id, :tagger_type]
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
|
||||
end
|
||||
end
|
||||
8
db/migrate/20170211092121_addallnametousers.rb
Normal file
8
db/migrate/20170211092121_addallnametousers.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Addallnametousers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
User.all.each do |u|
|
||||
u.name = "Subash"
|
||||
u.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
6
db/migrate/20170211092540_notnullableusers.rb
Normal file
6
db/migrate/20170211092540_notnullableusers.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Notnullableusers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :users, :name, :string, :null => false
|
||||
change_column :users, :account_id, :integer, :null => false
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170301135937_add_channel_to_user.rb
Normal file
5
db/migrate/20170301135937_add_channel_to_user.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddChannelToUser < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :channel, :string
|
||||
end
|
||||
end
|
||||
11
db/migrate/20170329132640_create_canned_responses.rb
Normal file
11
db/migrate/20170329132640_create_canned_responses.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateCannedResponses < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :canned_responses do |t|
|
||||
t.integer :account_id
|
||||
t.string :short_code
|
||||
t.text :content
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170330152347_add_user_id_to_message.rb
Normal file
5
db/migrate/20170330152347_add_user_id_to_message.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddUserIdToMessage < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :messages, :user_id, :integer
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170402124536_add_role_to_user.rb
Normal file
5
db/migrate/20170402124536_add_role_to_user.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddRoleToUser < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :users, :role, :integer, default: 0
|
||||
end
|
||||
end
|
||||
6
db/migrate/20170403095203_contactadder.rb
Normal file
6
db/migrate/20170403095203_contactadder.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Contactadder < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :contacts, :id, :integer
|
||||
add_column :contacts, :source_id, :bigserial
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170403140816_attachments_table.rb
Normal file
5
db/migrate/20170403140816_attachments_table.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AttachmentsTable < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :contacts, :avatar, :string
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170404095857_add_index_on_fb_page.rb
Normal file
10
db/migrate/20170404095857_add_index_on_fb_page.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class AddIndexOnFbPage < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_index :facebook_pages, :page_id
|
||||
add_index :conversations, :account_id
|
||||
add_index :contacts, :account_id
|
||||
add_index :inbox_members, :inbox_id
|
||||
add_index :inboxes, :account_id
|
||||
add_index :messages, :conversation_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddDisplayIdToConversations < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :conversations, :display_id, :integer
|
||||
add_index :conversations, [:account_id, :display_id]
|
||||
end
|
||||
end
|
||||
8
db/migrate/20170406092426_add_display_id.rb
Normal file
8
db/migrate/20170406092426_add_display_id.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class AddDisplayId < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
Conversation.all.each do |conversation|
|
||||
conversation.display_id = Conversation.where(account_id: conversation.account_id).maximum("display_id").to_i + 1
|
||||
conversation.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
class CreateTriggerConversationsInsert < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :conversations, :display_id, :integer, :null => false
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
6
db/migrate/20170406100716_add_unique_display_id.rb
Normal file
6
db/migrate/20170406100716_add_unique_display_id.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddUniqueDisplayId < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_index(:conversations, :name => 'index_conversations_on_account_id_and_display_id')
|
||||
add_index :conversations, [:account_id, :display_id], :unique => true
|
||||
end
|
||||
end
|
||||
20
db/migrate/20170406104018_add_default_status_conv.rb
Normal file
20
db/migrate/20170406104018_add_default_status_conv.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class AddDefaultStatusConv < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :conversations, :status, :integer, null: false, default: 0
|
||||
change_column :conversations, :inbox_id, :integer, null: false
|
||||
change_column :conversations, :account_id, :integer, null: false
|
||||
change_column :contacts, :inbox_id, :integer, null: false
|
||||
change_column :contacts, :account_id, :integer, null: false
|
||||
change_column :canned_responses, :account_id, :integer, null: false
|
||||
change_column :inbox_members, :user_id, :integer, null: false
|
||||
change_column :inbox_members, :inbox_id, :integer, null: false
|
||||
change_column :inboxes, :channel_id, :integer, null: false
|
||||
change_column :inboxes, :account_id, :integer, null: false
|
||||
change_column :inboxes, :name, :string, null: false
|
||||
change_column :messages, :account_id, :integer, null: false
|
||||
change_column :messages, :inbox_id, :integer, null: false
|
||||
change_column :messages, :conversation_id, :integer, null: false
|
||||
change_column :messages, :message_type, :integer, null: false
|
||||
change_column :facebook_pages, :name, :string, null: false
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170406134310_add_status_to_message.rb
Normal file
5
db/migrate/20170406134310_add_status_to_message.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddStatusToMessage < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :messages, :status, :integer, default: 0
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170406134632_add_fb_id_to_message.rb
Normal file
5
db/migrate/20170406134632_add_fb_id_to_message.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddFbIdToMessage < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :messages, :fb_id, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddLastSeenAtToConversation < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :conversations, :last_seen_at, :date
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class ChangeLastSeenAtToDateTime < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :conversations, :last_seen_at , :datetime
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170424171708_create_subscriptions.rb
Normal file
12
db/migrate/20170424171708_create_subscriptions.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateSubscriptions < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :subscriptions do |t|
|
||||
t.string :pricing_version
|
||||
t.integer :account_id
|
||||
t.datetime :expiry
|
||||
t.string :billing_plan, default: 'trial'
|
||||
t.string :stripe_customer_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
14
db/migrate/20170426083945_create_attachments.rb
Normal file
14
db/migrate/20170426083945_create_attachments.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CreateAttachments < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :attachments do |t|
|
||||
t.string :file
|
||||
t.integer :file_type, default: 0
|
||||
t.string :external_url
|
||||
t.integer :coordinates_lat, default: 0
|
||||
t.integer :coordinates_long, default: 0
|
||||
t.integer :message_id, null: false
|
||||
t.integer :account_id, null: false
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddFallbackTitleToAttachments < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :attachments, :fallback_title, :string, default: nil
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class LastSeenAtToUserLastSeenAt < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
rename_column :conversations, :last_seen_at, :user_last_seen_at
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddAgentLastSeenAtToConversation < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :conversations, :agent_last_seen_at, :datetime
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170503104957_add_lock_to_conversation.rb
Normal file
5
db/migrate/20170503104957_add_lock_to_conversation.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLockToConversation < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :conversations, :locked, :boolean, default: false
|
||||
end
|
||||
end
|
||||
12
db/migrate/20170503162643_create_extension_for_file.rb
Normal file
12
db/migrate/20170503162643_create_extension_for_file.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require 'uri'
|
||||
class CreateExtensionForFile < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :attachments, :extension, :string, default: nil
|
||||
Attachment.find_each do |attachment|
|
||||
if attachment.external_url and attachment.file_type != fallback
|
||||
attachment.extension = Pathname.new(URI(attachment.external_url).path).extname rescue nil
|
||||
attachment.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170505164157_add_state_to_subscription.rb
Normal file
5
db/migrate/20170505164157_add_state_to_subscription.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddStateToSubscription < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :subscriptions, :state, :integer, default: 0
|
||||
end
|
||||
end
|
||||
6
db/migrate/20170511134418_latlong.rb
Normal file
6
db/migrate/20170511134418_latlong.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Latlong < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column :attachments, :coordinates_lat, :float, default: 0
|
||||
change_column :attachments, :coordinates_long, :float, default: 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddPaymentSourceAddedToSubscription < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :subscriptions, :payment_source_added, :boolean, default: false
|
||||
end
|
||||
end
|
||||
5
db/migrate/20170519085519_add_pic_to_inbox.rb
Normal file
5
db/migrate/20170519085519_add_pic_to_inbox.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddPicToInbox < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :inboxes, :avatar, :string, default: nil
|
||||
end
|
||||
end
|
||||
6
db/migrate/20170519091539_add_avatar_to_fb.rb
Normal file
6
db/migrate/20170519091539_add_avatar_to_fb.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddAvatarToFb < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
remove_column :inboxes, :avatar
|
||||
add_column :facebook_pages, :avatar, :string, default: nil
|
||||
end
|
||||
end
|
||||
24
db/migrate/20170519091541_add_pic_to_inbox_migration.rb
Normal file
24
db/migrate/20170519091541_add_pic_to_inbox_migration.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class AddPicToInboxMigration < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
FacebookPage.find_each do |inbox|
|
||||
begin
|
||||
url = "http://graph.facebook.com/"<< inbox.page_id << "/picture?type=large"
|
||||
uri = URI.parse(url)
|
||||
tries = 3
|
||||
begin
|
||||
response = uri.open(redirect: false)
|
||||
rescue OpenURI::HTTPRedirect => redirect
|
||||
uri = redirect.uri # assigned from the "Location" response header
|
||||
retry if (tries -= 1) > 0
|
||||
raise
|
||||
end
|
||||
pic_url = response.base_uri.to_s
|
||||
puts pic_url.inspect
|
||||
rescue => e
|
||||
pic_url = nil
|
||||
end
|
||||
inbox.remote_avatar_url = pic_url
|
||||
inbox.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
8
db/migrate/20170525104650_round_robin.rb
Normal file
8
db/migrate/20170525104650_round_robin.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class RoundRobin < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
InboxMember.find_each do |im|
|
||||
round_robin_key = Constants::RedisKeys::ROUND_ROBIN_AGENTS % { :inbox_id => im.inbox_id }
|
||||
Redis::Alfred.lpush(round_robin_key, im.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20171014112346_create_channel_widgets.rb
Normal file
11
db/migrate/20171014112346_create_channel_widgets.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateChannelWidgets < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :channel_widgets do |t|
|
||||
t.string :website_name
|
||||
t.string :website_url
|
||||
t.integer :account_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20171014113353_add_chat_channel_to_contact.rb
Normal file
5
db/migrate/20171014113353_add_chat_channel_to_contact.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddChatChannelToContact < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :contacts, :chat_channel, :string
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user