gpt4 book ai didi

ruby-on-rails - 索引名称 "index_name"太长;限制为 63 个字符

转载 作者:行者123 更新时间:2023-11-29 14:32:10 27 4
gpt4 key购买 nike

<分区>

当我运行 rails migration 命令时。我得到的索引名称太长。我的迁移文件

class AddMissingIndices < ActiveRecord::Migration
def change
# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_conversation_opt_outs, [:unsubscriber_id, :unsubscriber_type],
name: 'index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type'
add_index :mailboxer_conversation_opt_outs, :conversation_id

add_index :mailboxer_notifications, :type
add_index :mailboxer_notifications, [:sender_id, :sender_type]

# We'll explicitly specify its name, as the auto-generated name is too long and exceeds 63
# characters limitation.
add_index :mailboxer_notifications, [:notified_object_id, :notified_object_type],
name: 'index_mailboxer_notifications_on_notified_object_id_and_type'

add_index :mailboxer_receipts, [:receiver_id, :receiver_type]
end
end

服务器日志是

rails aborted!

StandardError: An error has occurred, this and all later migrations canceled:

Index name 'index_mailboxer_conversation_opt_outs_on_unsubscriber_type_and_unsubscriber_id' on table 'mailboxer_conversation_opt_outs' is too long; the limit is 63 characters /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:1353:in validate_index_length!'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:1166:in
add_index_options' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql/schema_statements.rb:465:in add_index'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:315:in
block in create_table' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in each'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:314:in
create_table' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:871:in block in method_missing'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:840:in
block in say_with_time' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:840:in say_with_time'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:860:in
method_missing' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration/compatibility.rb:36:in create_table'
/home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration/compatibility.rb:75:in
create_table' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:604:in method_missing'
/home/sharat/rahul/Fleet-Latest/db/migrate/20170425092621_add_conversation_optout.mailboxer_engine.rb:4:in
up' /home/sharat/.rvm/gems/ruby-2.4.3/gems/activerecord-5.2.0/lib/active_record/migration.rb:777:in `up'

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com