diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-10 22:49:08 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-11 14:15:16 +0900 |
commit | da5843436b416f5c730f552273e1d09002beb4e0 (patch) | |
tree | b96c0b39eef34cd4c3a572cfc0b56b2797e50399 /activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | |
parent | d87afbf46f87a7fb8e9fef5c1b8422cdf386f4cb (diff) | |
download | rails-da5843436b416f5c730f552273e1d09002beb4e0.tar.gz rails-da5843436b416f5c730f552273e1d09002beb4e0.tar.bz2 rails-da5843436b416f5c730f552273e1d09002beb4e0.zip |
SQLite3: Implement `add_foreign_key` and `remove_foreign_key`
I implemented Foreign key create in `create_table` for SQLite3 at
#24743. This follows #24743 to implement `add_foreign_key` and
`remove_foreign_key`.
Unfortunately SQLite3 has one limitation that
`PRAGMA foreign_key_list(table-name)` doesn't have constraint name.
So we couldn't implement find/remove foreign key by name for now.
Fixes #35207.
Closes #31343.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 02bbe1ea45..9f28fdf749 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -121,7 +121,7 @@ module ActiveRecord true end - def supports_foreign_keys_in_create? + def supports_foreign_keys? true end @@ -424,9 +424,8 @@ module ActiveRecord type.to_sym == :primary_key || options[:primary_key] end - def alter_table(table_name, options = {}) + def alter_table(table_name, foreign_keys = foreign_keys(table_name), **options) altered_table_name = "a#{table_name}" - foreign_keys = foreign_keys(table_name) caller = lambda do |definition| rename = options[:rename] || {} |