Giter Club home page Giter Club logo

schema_plus_foreign_keys's People

Contributors

boazy avatar btsuhako avatar dholdren avatar felipemaier avatar kushkella avatar lowjoel avatar ronen avatar urkle avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schema_plus_foreign_keys's Issues

Renaming a table removes and re-adds FK constraints with no option to disable

Hi,

My app has a very large table (lets call it articles) and another slightly smaller table called comments. I added a migration to rename the comments table to messages and was very surprised to see our app blow up when the migration started hanging. After some research it appeared that a constraint was being removed and re-added here. I understand the constraint is being removed and re-added because it cannot be renamed in all cases, but I would expect there to be some way to disable this. Since the following migration:

def change
  rename_table :comments, :messages
end

Appears to have no side affects. Changing the name of the constraints isn't a necessity so it would be nice to turn this off.

Also, in PostgreSQL versions later than 9.2, it's possible to rename a constraint:

alter table messages rename constraint fk_comments_article_id to fk_messages_article_id

Is it possible to have a configuration option to enable constraint renaming or at the very least, disable removing and re-creating these constraints?

Configuration typo in readme

The readme currently says:

SchemaPlus::ForeignKey.setup do |config|
    config.on_update = :cascade   # default is nil, meaning use default dbms behavior
    config.on_delete = :nullify   # default is nil, meaning use default dbms behavior
end

But I think it should be:

SchemaPlus::ForeignKeys.setup do |config|
    config.on_update = :cascade   # default is nil, meaning use default dbms behavior
    config.on_delete = :nullify   # default is nil, meaning use default dbms behavior
end

Note the added "s" on end of SchemaPlus::ForeignKeys.

docfix: name attribute for foreign key should be specified in index

Specifying

    create_table :course_assessment_question_multiple_response_options do |t|
      t.references :question,
                   null: false,
                   foreign_key: {
                     name: :fk__course_assessment_multiple_response_option_question,
                     references: :course_assessment_question_multiple_responses
                   }
    end

errors with a name too long error. This works:

    create_table :course_assessment_question_multiple_response_options do |t|
      t.references :question,
                   null: false,
                   index: {
                     name: :fk__course_assessment_multiple_response_option_question,
                   },
                   foreign_key: {
                     references: :course_assessment_question_multiple_responses
                   }
    end

Rails 5 incompatibility

I'm having a problem using this gem with Rails 5.1.0.beta1. I open an issue there rails/rails#28192, but I think the problem is with schema_plus_foreign_keys

While using this gem, when I execute Event.last.administrators.to_sql in a class like this:

class Event < ApplicationRecord
  has_and_belongs_to_many :administrators, class_name: User
end

I get the following:
"SELECT \"users\".* FROM \"users\" WHERE \"users\".\"event_id\" = 1"

Instead of:
"SELECT \"users\".* FROM \"users\" INNER JOIN \"events_users\" ON \"users\".\"id\" = \"events_users\".\"user_id\" WHERE \"events_users\".\"event_id\" = 1"

Project status update?

Hi,

Just seeing if this project is still active and accepting PRs?

We use various schema_plus* gems in our Rails 4.2 apps, but are looking at upgrading to Rails 5.2, which isn't currently supported.

I can see there is PR #15 for Rails 5.2 support, but that just changes the gemspec. Would you be open to a PR for Rails 5.2 support?

Thanks!

Joe.

remove_foreign_key: undefined local variable or method `its'

Hi,

Your latest release (0.1.5) causes an error when calling 'remove_foreign_key' in migrations. Requiring 'its-it' explicitly in Gemfile fixes it, so I guess it just needs to be required somewhere.

undefined local variable or method `its' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x007fc48ce854b0>
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/schema_plus_foreign_keys-0.1.5/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb:109:in `get_foreign_key_name'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/schema_plus_foreign_keys-0.1.5/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb:123:in `remove_foreign_key_sql'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/schema_plus_foreign_keys-0.1.5/lib/schema_plus/foreign_keys/active_record/connection_adapters/abstract_adapter.rb:70:in `remove_foreign_key'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:665:in `block in method_missing'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:634:in `block in say_with_time'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:634:in `say_with_time'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:654:in `method_missing'
/Users/nedforce/projects/my_project/db/migrate/20160530151530_remove_foreign_key_from_permit_archives.rb:8:in `up'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:773:in `migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:1003:in `block in execute_migration_in_transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:1049:in `block in ddl_transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/transactions.rb:220:in `transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:1049:in `ddl_transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:1002:in `execute_migration_in_transaction'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:964:in `block in migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:960:in `each'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:960:in `migrate'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:828:in `up'
/Users/nedforce/.rvm/gems/ruby-2.2.2@devcms/gems/activerecord-4.2.6/lib/active_record/migration.rb:806:in `migrate'

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.