diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-06-10 14:26:50 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-26 22:03:48 +0200 |
commit | 402f303f1d938cf2c7781d7734c4ff8e6b874f35 (patch) | |
tree | d96eb08bab6f5fc63f9f8a9a7fe2086d24c9e7e4 /activerecord/lib/active_record/connection_adapters/postgresql | |
parent | 69c711f38cac85e9c8bdbe286591bf88ef720bfa (diff) | |
download | rails-402f303f1d938cf2c7781d7734c4ff8e6b874f35.tar.gz rails-402f303f1d938cf2c7781d7734c4ff8e6b874f35.tar.bz2 rails-402f303f1d938cf2c7781d7734c4ff8e6b874f35.zip |
fk: support dependent option (:delete, :nullify and :restrict).
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index c061337e71..7b61ff81ba 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -467,7 +467,14 @@ ORDER BY c.conname options = { column: row['column'], name: row['name'], - primary_key: row['primary_key'] } + primary_key: row['primary_key'] + } + + options[:dependent] = case row['dependency'] + when 'c'; :delete + when 'n'; :nullify + when 'r'; :restrict + end ForeignKeyDefinition.new(table_name, row["to_table"], options) end end |