-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2547 from DFE-Digital/AQTS-688-dev-code-architect…
…ure-update-new-trs-trn-request-table [AQTS-688] New trs_trn_requests table to replace dqt_trn_requests
- Loading branch information
Showing
25 changed files
with
555 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: trs_trn_requests | ||
# | ||
# id :bigint not null, primary key | ||
# potential_duplicate :boolean | ||
# state :string default("initial"), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# application_form_id :bigint not null | ||
# request_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_trs_trn_requests_on_application_form_id (application_form_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (application_form_id => application_forms.id) | ||
# | ||
class TRSTRNRequest < ApplicationRecord | ||
belongs_to :application_form | ||
|
||
enum :state, | ||
{ initial: "initial", pending: "pending", complete: "complete" }, | ||
default: :initial | ||
validates :state, presence: true, inclusion: { in: states.values } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateTRSTRNRequests < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :trs_trn_requests do |t| | ||
t.references :application_form, null: false, foreign_key: true | ||
t.uuid :request_id, null: false | ||
t.string :state, null: false, default: "pending" | ||
t.boolean :potential_duplicate | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "ruby-progressbar" | ||
|
||
namespace :dqt_to_trs_migration do | ||
desc "Backfill the trs_trn_requests table with what is within dqt_trn_requests" | ||
task replace_dqt_trn_requests_table_with_trs_trn_requests: :environment do | ||
progressbar = | ||
ProgressBar.create(name: "Creation", count: DQTTRNRequest.count) # rubocop:disable Rails/SaveBang | ||
|
||
ActiveRecord::Base.transaction do | ||
DQTTRNRequest.find_each do |dqt_trn_request| | ||
progressbar.increment | ||
|
||
TRSTRNRequest.create!( | ||
potential_duplicate: dqt_trn_request.potential_duplicate, | ||
state: dqt_trn_request.state, | ||
created_at: dqt_trn_request.created_at, | ||
updated_at: dqt_trn_request.updated_at, | ||
application_form_id: dqt_trn_request.application_form_id, | ||
request_id: dqt_trn_request.request_id, | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: trs_trn_requests | ||
# | ||
# id :bigint not null, primary key | ||
# potential_duplicate :boolean | ||
# state :string default("initial"), not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# application_form_id :bigint not null | ||
# request_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_trs_trn_requests_on_application_form_id (application_form_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (application_form_id => application_forms.id) | ||
# | ||
FactoryBot.define do | ||
factory :trs_trn_request do | ||
association :application_form, :awarded_pending_checks | ||
|
||
request_id { SecureRandom.uuid } | ||
|
||
trait :potential_duplicate do | ||
potential_duplicate { true } | ||
end | ||
end | ||
end |
Oops, something went wrong.