Skip to content

Commit

Permalink
Merge pull request #2100 from alphagov/PP-6065-remove_foreign_key_con…
Browse files Browse the repository at this point in the history
…straint_from_refunds

PP-6065 remove foreign key constrain on charge_id on refunds table
  • Loading branch information
SandorArpa authored Feb 12, 2020
2 parents 6fb730f + b1164af commit 0404841
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/resources/migrations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1430,4 +1430,36 @@
</createIndex>
</changeSet>

<changeSet id="drop foreign key constraint on charge_id on refunds table" author="">
<dropForeignKeyConstraint
baseTableName="refunds"
constraintName="fk__refunds_charges"/>
</changeSet>

<changeSet author="" id="drop not null constraint on charge_id on refunds table">
<dropNotNullConstraint columnDataType="bigserial"
columnName="charge_id"
tableName="refunds"/>
</changeSet>

<changeSet author="" id="drop not null constraint on charge_id refunds_history table">
<dropNotNullConstraint columnDataType="bigserial"
columnName="charge_id"
tableName="refunds_history"/>
</changeSet>

<changeSet id="drop index on charge_id on refunds table" author="">
<dropIndex tableName="refunds" indexName="idx_refunds_charge_id"/>
</changeSet>

<changeSet id="drop index on charge_id on refunds_history table" author="">
<dropIndex tableName="refunds_history" indexName="idx_refunds_history_charge_id"/>
</changeSet>

<changeSet id="create charge_external_id index on refunds_history table" runInTransaction="false" author="">
<sql>
CREATE INDEX CONCURRENTLY idx_refunds_history_charge_external_id ON refunds_history (charge_external_id);
</sql>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ public void truncateAllData() {
jdbi.withHandle(h -> h.createUpdate("TRUNCATE TABLE gateway_accounts CASCADE").execute());
jdbi.withHandle(h -> h.createUpdate("TRUNCATE TABLE emitted_events CASCADE").execute());
jdbi.withHandle(h -> h.createUpdate("TRUNCATE TABLE tokens").execute());
jdbi.withHandle(h -> h.createUpdate("TRUNCATE TABLE refunds").execute());
jdbi.withHandle(h -> h.createUpdate("TRUNCATE TABLE refunds_history").execute());
}

public Long getChargeIdByExternalId(String externalChargeId) {
Expand Down

0 comments on commit 0404841

Please sign in to comment.