From 402f303f1d938cf2c7781d7734c4ff8e6b874f35 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 10 Jun 2014 14:26:50 +0200 Subject: fk: support dependent option (:delete, :nullify and :restrict). --- .../connection_adapters/postgresql/schema_statements.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql') 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 -- cgit v1.2.3