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)


17
18
19
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 17

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



25
26
27
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 25

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

#remove_foreign_key(table_name, *args) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 21

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



29
30
31
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 29

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)


13
14
15
# File 'lib/schema_plus/foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb', line 13

def supports_foreign_keys?
  true
end