mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add back schema migration for unique securities
This commit is contained in:
parent
fcdc42760d
commit
c7d9c94489
2 changed files with 15 additions and 2 deletions
|
@ -0,0 +1,13 @@
|
|||
class StrongerUniqueIndexOnSecurity < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
remove_index :securities, [ :ticker, :exchange_operating_mic ], unique: true
|
||||
|
||||
# Matches our ActiveRecord validation:
|
||||
# - uppercase ticker
|
||||
# - either exchange_operating_mic or empty string (unique index doesn't work with NULL values)
|
||||
add_index :securities,
|
||||
"UPPER(ticker), COALESCE(UPPER(exchange_operating_mic), '')",
|
||||
unique: true,
|
||||
name: "index_securities_on_ticker_and_exchange_operating_mic_unique"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue