Enforce uniqueness on heartbeats

This commit is contained in:
Max Wofford
2025-03-05 15:42:53 -05:00
parent 5f6bd02406
commit 0a41007e9d
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
class EnforceUniquenessIndexOnHeartbeats < ActiveRecord::Migration[8.0]
def change
add_index :heartbeats, :fields_hash, unique: true, if_not_exists: true
end
end

3
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_03_05_194250) do
ActiveRecord::Schema[8.0].define(version: 2025_03_05_195904) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
@@ -140,6 +140,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_05_194250) do
t.datetime "updated_at", null: false
t.text "fields_hash"
t.integer "source_type", default: 0, null: false
t.index ["fields_hash"], name: "index_heartbeats_on_fields_hash", unique: true
t.index ["user_id"], name: "index_heartbeats_on_user_id"
end