parent
d7a8574c6e
commit
3f9dc3747b
1 changed files with 7 additions and 7 deletions
|
@ -1,14 +1,14 @@
|
||||||
# db/migrate/20240612000000_add_local_top_algorithm_support.rb
|
# db/migrate/20240612000000_add_local_top_algorithm_support.rb
|
||||||
class AddLocalTopAlgorithmSupport < ActiveRecord::Migration[8.0]
|
class AddLocalTopAlgorithmSupport < ActiveRecord::Migration[8.0]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction! # Allows concurrent operations
|
||||||
|
|
||||||
def change
|
def change
|
||||||
# Safe to add immediately
|
# 1. Add reference without immediate foreign key validation
|
||||||
add_column :users, :feed_algorithm, :string, default: 'chronological'
|
|
||||||
|
|
||||||
# Add reference without foreign key constraint first
|
|
||||||
add_reference :statuses, :status_stat,
|
add_reference :statuses, :status_stat,
|
||||||
index: { algorithm: :concurrently },
|
index: { algorithm: :concurrently }, # Concurrent index
|
||||||
foreign_key: false
|
foreign_key: { on_delete: :cascade, validate: false } # Defer validation
|
||||||
|
|
||||||
|
# 2. Add user preference column (safe operation)
|
||||||
|
add_column :users, :feed_algorithm, :string, default: 'chronological'
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue