Skip to content

Commit

Permalink
Alter and add migration for amendAllocated column two-part tariff rev…
Browse files Browse the repository at this point in the history
…iew (#975)

Oppsie, I messed up!
During testing for the two-part tariff review screens, it was noted that some of the data for a charge element allocated volume wasn't persisting correctly. This is due to the table's column not being the correct data type.
The initial migration for the creation of the column calculated (now called amended_allocated) was on April 17th.
The column wasn't created properly and needed to be amended so that the decimal points weren't getting cut off.
Having checked the commit history in the repo there were no tags at the time, so rather than create a new migration, I went and edited the original migration instead.
This is where my oppsie happened.
The edited migration commit happened on the 17th (before the repo got tagged for release) however due to the length of PR I was working on, the actual PR itself didn't get merged until the 24th. The repo got tagged for a release between this on the 19th. This means the initial migration has been run on production and the edited version of the migration will not work for updating the column data type.
This PR reverts the migration file to its original state and adds a new migration that can be run to update the column data type. facepalm
  • Loading branch information
Beckyrose200 authored May 3, 2024
1 parent 45912bc commit f1c4f95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.up = async function (knex) {
return knex
.schema
.alterTable(tableName, (table) => {
table.decimal('calculated', null, null).defaultTo(0)
table.decimal('calculated')
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict'

const tableName = 'review_charge_elements'

exports.up = async function (knex) {
return knex
.schema
.alterTable(tableName, (table) => {
table.decimal('amended_allocated', null, null).defaultTo(0).alter()
})
}

exports.down = async function (knex) {
return knex
.schema
.alterTable(tableName, (table) => {
table.decimal('amended_allocated').alter()
})
}

0 comments on commit f1c4f95

Please sign in to comment.