Sha256: 987786bdd0210805c4c0336f684387ab1b0ea036442d2414178c3463ce67adab

Contents?: true

Size: 623 Bytes

Versions: 8

Compression:

Stored size: 623 Bytes

Contents

module Inkling
  module Util
    module MigrationHelpers
      def add_foreign_key(from_table, from_column, to_table)
        constraint_name = "fk_#{from_table}_#{from_column}"

        execute %{alter table #{from_table}
                  add constraint #{constraint_name}
                  foreign key (#{from_column})
                  references #{to_table}(id)}
      end


      def remove_foreign_key(from_table, from_column)
        constraint_name = "fk_#{from_table}_#{from_column}"

        execute %{alter table #{from_table}
                   drop foreign key #{constraint_name}}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
inkling-0.1.0 lib/inkling/util/migration_helpers.rb
inkling-0.0.9 lib/inkling/util/migration_helpers.rb
inkling-0.0.8 lib/inkling/util/migration_helpers.rb
inkling-0.0.7 lib/inkling/util/migration_helpers.rb
inkling-0.0.5 lib/inkling/util/migration_helpers.rb
inkling-0.0.4 lib/inkling/util/migration_helpers.rb
inkling-0.0.3a lib/inkling/util/migration_helpers.rb
inkling-0.0.3 lib/inkling/util/migration_helpers.rb