Module: SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters::Sqlite3Adapter

Defined in:
lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb

Overview

SchemaPlus::ForeignKeys includes an Sqlite3 implementation of the AbstractAdapter extensions.

Instance Method Summary collapse

Instance Method Details

#add_foreign_key(table_name, to_table, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 19

def add_foreign_key(table_name, to_table, options = {})
  raise NotImplementedError, "Sqlite3 does not support altering a table to add foreign key constraints (table #{table_name.inspect} to #{to_table.inspect})"
end

#foreign_keys(table_name, name = nil) ⇒ Object



27
28
29
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 27

def foreign_keys(table_name, name = nil)
  get_foreign_keys(table_name, name)
end

#remove_foreign_key(table_name, *args) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 23

def remove_foreign_key(table_name, *args)
  raise NotImplementedError, "Sqlite3 does not support altering a table to remove foreign key constraints (table #{table_name.inspect} constraint #{args.inspect})"
end

#reverse_foreign_keys(table_name, name = nil) ⇒ Object



31
32
33
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 31

def reverse_foreign_keys(table_name, name = nil)
  get_foreign_keys(nil, name).select{|definition| definition.to_table == table_name}
end

#supports_foreign_keys?Boolean

Even though SQLite3 has limited support for foreign keys, ActiveRecord does not enable it by default.

Returns:

  • (Boolean)


15
16
17
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 15

def supports_foreign_keys?
  true
end