Sha256: b126a00a82eda826a679deeb5158f4899b5165d51ac1967f76bf3b4d0392d023
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module SchemaPlusForeignKeys::ActiveRecord::ConnectionAdapters module SchemaStatements def self.included(base) #:nodoc: base.class_eval do alias_method_chain :create_table, :schema_plus_foreign_keys end end ## # :method: create_table # # SchemaPlusForeignKeys extends SchemaStatements::create_table to allow you to specify configuration options per table. Pass them in as a hash keyed by configuration set (see SchemaPlusForeignKeys::Config), # for example: # # create_table :widgets, :foreign_keys => {:auto_create => true, :on_delete => :cascade} do |t| # ... # end def create_table_with_schema_plus_foreign_keys(table, options = {}) options = options.dup config_options = options.delete(:foreign_keys) || {} # override rails' :force to cascade drop_table(table, if_exists: true, cascade: true) if options.delete(:force) create_table_without_schema_plus_foreign_keys(table, options) do |table_definition| table_definition.schema_plus_config = SchemaPlusForeignKeys.config.merge(config_options) yield table_definition if block_given? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schema_plus-2.0.0.pre3 | lib/schema_plus_foreign_keys/active_record/connection_adapters/schema_statements.rb |