add is first to completed submitters
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# completed_at :datetime not null
|
||||
# is_first :boolean
|
||||
# sms_count :integer not null
|
||||
# source :string not null
|
||||
# verification_method :string
|
||||
@@ -18,8 +19,10 @@
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_completed_submitters_on_account_id (account_id)
|
||||
# index_completed_submitters_on_submitter_id (submitter_id) UNIQUE
|
||||
# index_completed_submitters_on_account_id (account_id)
|
||||
# index_completed_submitters_on_account_id_and_completed_at (account_id,completed_at) WHERE (is_first = true)
|
||||
# index_completed_submitters_on_submission_id (submission_id) UNIQUE WHERE (is_first = true)
|
||||
# index_completed_submitters_on_submitter_id (submitter_id) UNIQUE
|
||||
#
|
||||
class CompletedSubmitter < ApplicationRecord
|
||||
belongs_to :submitter
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddIsFirstToCompletedSubmitters < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
# rubocop:disable Rails/ThreeStateBooleanColumn
|
||||
add_column :completed_submitters, :is_first, :boolean
|
||||
# rubocop:enable Rails/ThreeStateBooleanColumn
|
||||
|
||||
add_index :completed_submitters, %i[account_id completed_at], where: 'is_first = TRUE'
|
||||
add_index :completed_submitters, :submission_id, unique: true, where: 'is_first = TRUE'
|
||||
end
|
||||
end
|
||||
+4
-1
@@ -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_11_21_090556) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_11_21_092044) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "plpgsql"
|
||||
@@ -118,7 +118,10 @@ ActiveRecord::Schema[8.0].define(version: 2025_11_21_090556) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "verification_method"
|
||||
t.boolean "is_first"
|
||||
t.index ["account_id", "completed_at"], name: "index_completed_submitters_on_account_id_and_completed_at", where: "(is_first = true)"
|
||||
t.index ["account_id"], name: "index_completed_submitters_on_account_id"
|
||||
t.index ["submission_id"], name: "index_completed_submitters_on_submission_id", unique: true, where: "(is_first = true)"
|
||||
t.index ["submitter_id"], name: "index_completed_submitters_on_submitter_id", unique: true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user