Code Monkey home page Code Monkey logo

activerecord-simple_index_name's Introduction

activerecord-simple_index_name's People

Contributors

dependabot[bot] avatar onk avatar sue445 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

onk

activerecord-simple_index_name's Issues

Support optin

Now

if required , all index are shorten

New feature

  • choose default shorten mode
    • ON: not changed
    • OFF: default is not shorten, but can enable shorten index in specify migration

TODO

  • [config] auto_shorten #13
  • [migration] enable_shorten #12
  • [migration] disable_shorten #12

Support rename_table

Migrations

class CreateOldTable < ActiveRecord::CompatibleLegacyMigration.migration_class
  include ActiveRecord::SimpleIndexName::EnableShorten

  def change
    create_table :old_table do |t|
      t.string :anonymous_name, null: false
      t.timestamps null: false
    end
    add_index :old_table, :anonymous_name
  end
end
class RenameOldTableToNewTable < ActiveRecord::CompatibleLegacyMigration.migration_class
  def change
    rename_table :old_table, :new_table
  end
end

Error

  1) ActiveRecord::ConnectionAdapters::SchemaStatements#index_name_with_simple When auto_shorten is enabled When single column index
     Failure/Error: rename_table :old_table, :new_table

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

       Index name 'anonymous_name' on table 'new_table' already exists
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:939:in `add_index_options'
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:556:in `add_index'
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:598:in `rename_index'
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:998:in `block in rename_table_indexes'
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:995:in `each'
     # ./vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:995:in `rename_table_indexes'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.