mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Stronger security unique index and data migration
Note to self hosters: If you started self hosting prior to this commit, you may have duplicate securities in your database. This is usually not a problem, but if you'd like to clean things up, you can run the data migration by opening a terminal on the machine you're hosting with and running: ```sh rake data_migration:migrate_duplicate_securities ```
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
class StrongerUniquenessConstraintOnSecurities < 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
|
||||
Reference in New Issue
Block a user