Upgrade to rails 6 💎 (#11)

- upgraded to rails 6
- fixes various issues
This commit is contained in:
Sojan Jose
2019-08-19 01:19:57 -07:00
committed by Pranav Raj S
parent 3c32103e34
commit 52194116b3
53 changed files with 819 additions and 605 deletions

View File

@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 1)
class ActsAsTaggableOnMigration < ActiveRecord::Migration
class ActsAsTaggableOnMigration < ActiveRecord::Migration[5.0]
def self.up
create_table :tags do |t|
t.string :name
@@ -20,7 +20,6 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
t.datetime :created_at
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end

View File

@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 2)
class AddMissingUniqueIndices < ActiveRecord::Migration
class AddMissingUniqueIndices < ActiveRecord::Migration[5.0]
def self.up
add_index :tags, :name, unique: true

View File

@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 3)
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[5.0]
def self.up
add_column :tags, :taggings_count, :integer, default: 0

View File

@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 4)
class AddMissingTaggableIndex < ActiveRecord::Migration
class AddMissingTaggableIndex < ActiveRecord::Migration[5.0]
def self.up
add_index :taggings, [:taggable_id, :taggable_type, :context]
end

View File

@@ -1,7 +1,7 @@
# 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
class ChangeCollationForTagNames < ActiveRecord::Migration[5.0]
def up
if ActsAsTaggableOn::Utils.using_mysql?
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")

View File

@@ -1,5 +1,5 @@
# This migration comes from acts_as_taggable_on_engine (originally 6)
class AddMissingIndexes < ActiveRecord::Migration
class AddMissingIndexes < ActiveRecord::Migration[5.0]
def change
add_index :taggings, :tag_id
add_index :taggings, :taggable_id

View File

@@ -1,5 +1,5 @@
class CreateTriggerConversationsInsert < ActiveRecord::Migration
class CreateTriggerConversationsInsert < ActiveRecord::Migration[5.0]
def up
change_column :conversations, :display_id, :integer, :null => false
end

View File

@@ -0,0 +1,23 @@
# This migration comes from acts_as_taggable_on_engine (originally 6)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
else
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
end
AddMissingIndexesOnTaggings.class_eval do
def change
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_id
add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type
add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id
add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
unless index_exists? ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
end
unless index_exists? ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
end
end
end

View File

@@ -0,0 +1,8 @@
class CreateChannels < ActiveRecord::Migration[6.1]
def change
create_table :channels do |t|
t.string :name
t.timestamps
end
end
end

View File

@@ -2,204 +2,212 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171014113353) do
ActiveRecord::Schema.define(version: 2019_08_19_010457) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "accounts", force: :cascade do |t|
t.string "name"
create_table "accounts", id: :serial, force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "attachments", force: :cascade do |t|
t.string "file"
t.integer "file_type", default: 0
t.string "external_url"
t.float "coordinates_lat", default: 0.0
t.float "coordinates_long", default: 0.0
t.integer "message_id", null: false
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "fallback_title"
t.string "extension"
create_table "attachments", id: :serial, force: :cascade do |t|
t.string "file"
t.integer "file_type", default: 0
t.string "external_url"
t.float "coordinates_lat", default: 0.0
t.float "coordinates_long", default: 0.0
t.integer "message_id", null: false
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "fallback_title"
t.string "extension"
end
create_table "canned_responses", force: :cascade do |t|
t.integer "account_id", null: false
t.string "short_code"
t.text "content"
create_table "canned_responses", id: :serial, force: :cascade do |t|
t.integer "account_id", null: false
t.string "short_code"
t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "channel_widgets", force: :cascade do |t|
t.string "website_name"
t.string "website_url"
t.integer "account_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
create_table "channel_widgets", id: :serial, force: :cascade do |t|
t.string "website_name"
t.string "website_url"
t.integer "account_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "contacts", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "phone_number"
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "inbox_id", null: false
t.bigserial "source_id", null: false
t.string "avatar"
t.string "chat_channel"
t.index ["account_id"], name: "index_contacts_on_account_id", using: :btree
create_table "channels", force: :cascade do |t|
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "conversations", force: :cascade do |t|
t.integer "account_id", null: false
t.integer "inbox_id", null: false
t.integer "status", default: 0, null: false
t.integer "assignee_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "sender_id"
t.integer "display_id", null: false
create_table "contacts", id: :serial, force: :cascade do |t|
t.string "name"
t.string "email"
t.string "phone_number"
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "inbox_id", null: false
t.bigserial "source_id", null: false
t.string "avatar"
t.string "chat_channel"
t.index ["account_id"], name: "index_contacts_on_account_id"
end
create_table "conversations", id: :serial, force: :cascade do |t|
t.integer "account_id", null: false
t.integer "inbox_id", null: false
t.integer "status", default: 0, null: false
t.integer "assignee_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "sender_id"
t.integer "display_id", null: false
t.datetime "user_last_seen_at"
t.datetime "agent_last_seen_at"
t.boolean "locked", default: false
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true, using: :btree
t.index ["account_id"], name: "index_conversations_on_account_id", using: :btree
t.boolean "locked", default: false
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
t.index ["account_id"], name: "index_conversations_on_account_id"
end
create_table "facebook_pages", force: :cascade do |t|
t.string "name", null: false
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.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "avatar"
t.index ["page_id"], name: "index_facebook_pages_on_page_id", using: :btree
end
create_table "inbox_members", force: :cascade do |t|
t.integer "user_id", null: false
t.integer "inbox_id", null: false
create_table "facebook_pages", id: :serial, force: :cascade do |t|
t.string "name", null: false
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.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["inbox_id"], name: "index_inbox_members_on_inbox_id", using: :btree
t.string "avatar"
t.index ["page_id"], name: "index_facebook_pages_on_page_id"
end
create_table "inboxes", force: :cascade do |t|
t.integer "channel_id", null: false
t.integer "account_id", null: false
t.string "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "channel_type"
t.index ["account_id"], name: "index_inboxes_on_account_id", using: :btree
create_table "inbox_members", id: :serial, force: :cascade do |t|
t.integer "user_id", null: false
t.integer "inbox_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["inbox_id"], name: "index_inbox_members_on_inbox_id"
end
create_table "messages", force: :cascade do |t|
t.text "content"
t.integer "account_id", null: false
t.integer "inbox_id", null: false
t.integer "conversation_id", null: false
t.integer "message_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "private", default: false
t.integer "user_id"
t.integer "status", default: 0
t.string "fb_id"
t.index ["conversation_id"], name: "index_messages_on_conversation_id", using: :btree
create_table "inboxes", id: :serial, force: :cascade do |t|
t.integer "channel_id", null: false
t.integer "account_id", null: false
t.string "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "channel_type"
t.index ["account_id"], name: "index_inboxes_on_account_id"
end
create_table "subscriptions", force: :cascade do |t|
t.string "pricing_version"
t.integer "account_id"
create_table "messages", id: :serial, force: :cascade do |t|
t.text "content"
t.integer "account_id", null: false
t.integer "inbox_id", null: false
t.integer "conversation_id", null: false
t.integer "message_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "private", default: false
t.integer "user_id"
t.integer "status", default: 0
t.string "fb_id"
t.index ["conversation_id"], name: "index_messages_on_conversation_id"
end
create_table "subscriptions", id: :serial, force: :cascade 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.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "state", default: 0
t.boolean "payment_source_added", default: false
t.string "billing_plan", default: "trial"
t.string "stripe_customer_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "state", default: 0
t.boolean "payment_source_added", default: false
end
create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.string "taggable_type"
t.integer "taggable_id"
t.string "tagger_type"
t.integer "tagger_id"
t.string "context", limit: 128
create_table "taggings", id: :serial, force: :cascade do |t|
t.integer "tag_id"
t.string "taggable_type"
t.integer "taggable_id"
t.string "tagger_type"
t.integer "tagger_id"
t.string "context", limit: 128
t.datetime "created_at"
t.index ["context"], name: "index_taggings_on_context", using: :btree
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
t.index ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy", using: :btree
t.index ["taggable_id"], name: "index_taggings_on_taggable_id", using: :btree
t.index ["taggable_type"], name: "index_taggings_on_taggable_type", using: :btree
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type", using: :btree
t.index ["tagger_id"], name: "index_taggings_on_tagger_id", using: :btree
t.index ["context"], name: "index_taggings_on_context"
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
t.index ["tag_id"], name: "index_taggings_on_tag_id"
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable_type_and_taggable_id"
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
t.index ["tagger_type", "tagger_id"], name: "index_taggings_on_tagger_type_and_tagger_id"
end
create_table "tags", force: :cascade do |t|
t.string "name"
create_table "tags", id: :serial, force: :cascade do |t|
t.string "name"
t.integer "taggings_count", default: 0
t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree
t.index ["name"], name: "index_tags_on_name", unique: true
end
create_table "telegram_bots", force: :cascade do |t|
t.string "name"
t.string "auth_key"
t.integer "account_id"
create_table "telegram_bots", id: :serial, force: :cascade do |t|
t.string "name"
t.string "auth_key"
t.integer "account_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "provider", default: "email", null: false
t.string "uid", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
create_table "users", id: :serial, force: :cascade do |t|
t.string "provider", default: "email", null: false
t.string "uid", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
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"
t.string "confirmation_token"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.string "name", null: false
t.string "nickname"
t.string "image"
t.string "email"
t.json "tokens"
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "channel"
t.integer "role", default: 0
t.index ["email"], name: "index_users_on_email", using: :btree
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true, using: :btree
t.string "unconfirmed_email"
t.string "name", null: false
t.string "nickname"
t.string "image"
t.string "email"
t.json "tokens"
t.integer "account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "channel"
t.integer "role", default: 0
t.index ["email"], name: "index_users_on_email"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
end
end

View File

@@ -2,27 +2,29 @@ account = Account.create!([
{name: "Google"}
])
User.create!([
{email: "larry@google.com", encrypted_password: "$2a$11$CIyxMCfnm.FZ4arOR83AaORbgM7i2nrMPDKzxyfXd0fpkzumrWUlq", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, account_id: account.id}
])
user = User.new({name:"lary", email: "larry@google.com", password: "123456", account_id: account.first.id})
user.skip_confirmation!
user.save!
Channel.create!([
channels = Channel.create!([
{name: "Facebook Messenger"}
])
inboxes = Inbox.create!([
{channel: channels.first, account_id: 1, name: "Google Car"},
{channel: channels.first, account_id: 1, name: "Project Loon"}
])
Contact.create!([
{name: "izuck@facebook.com", email: nil, phone_number: "99496030692", channel_id: 1, account_id: 1}
{name: "izuck@facebook.com", email: nil, phone_number: "99496030692", inbox_id: inboxes.first.id, account_id: 1}
])
Conversation.create!([
{account_id: 1, channel_id: 1, inbox_id: 1, status: nil, assignee_id: 1, sender_id: 1}
])
Inbox.create!([
{channel_id: 1, account_id: 1, name: "Google Car"},
{channel_id: 1, account_id: 1, name: "Project Loon"}
{account_id: 1, inbox_id: 1, status: :open, assignee_id: 1, sender_id: 1}
])
InboxMember.create!([
{user_id: 1, inbox_id: 1}
])
Message.create!([
{content: "Hello", account_id: 1, channel_id: 1, inbox_id: 1, conversation_id: 1, type: nil}
{content: "Hello", account_id: 1, inbox_id: 1, conversation_id: 1, message_type: :incoming}
])