Skip to content

Commit

Permalink
feat: add rollback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Oct 12, 2023
1 parent 830e2d0 commit b1bde3d
Showing 1 changed file with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ exports.up = function (knex) {
'ALTER INDEX "paymentPointers_pkey" RENAME TO "walletAddresses_pkey"'
),
knex.raw(
'ALTER INDEX "paymentpointers_url_index" RENAME TO "walletAddresses_url_index"'
'ALTER INDEX "paymentpointers_url_index" RENAME TO "walletaddresses_url_index"'
),
knex.raw(
'ALTER INDEX "paymentpointers_processat_index" RENAME TO "walletAddresses_processat_index"'
'ALTER INDEX "paymentpointers_processat_index" RENAME TO "walletaddresses_processat_index"'
),
knex.raw(
'ALTER TABLE "walletAddresses" DROP CONSTRAINT "paymentpointers_url_unique"'
Expand All @@ -40,27 +40,21 @@ exports.up = function (knex) {
table.dropIndex(['paymentPointerId', 'createdAt', 'id'])
table.renameColumn('paymentPointerId', 'walletAddressId')
table.foreign('walletAddressId').references('walletAddresses.id')
table.index(['walletAddressId'])
table.index(['createdAt'])
table.index(['id'])
table.index(['walletAddressId', 'createdAt', 'id'])
}),
knex.schema.alterTable('incomingPayments', function (table) {
table.dropForeign(['paymentPointerId'])
table.dropIndex(['paymentPointerId', 'createdAt', 'id'])
table.renameColumn('paymentPointerId', 'walletAddressId')
table.foreign('walletAddressId').references('walletAddresses.id')
table.index(['walletAddressId'])
table.index(['createdAt'])
table.index(['id'])
table.index(['walletAddressId', 'createdAt', 'id'])
}),
knex.schema.alterTable('outgoingPayments', function (table) {
table.dropForeign(['paymentPointerId'])
table.dropIndex(['paymentPointerId', 'createdAt', 'id'])
table.renameColumn('paymentPointerId', 'walletAddressId')
table.foreign('walletAddressId').references('walletAddresses.id')
table.index(['walletAddressId'])
table.index(['createdAt'])
table.index(['id'])
table.index(['walletAddressId', 'createdAt', 'id'])
}),
knex('webhookEvents')
.update({
Expand Down Expand Up @@ -102,6 +96,25 @@ exports.up = function (knex) {
exports.down = function (knex) {
return Promise.all([
knex.schema.renameTable('walletAddresses', 'paymentPointers'),
knex.schema.alterTable('paymentPointers', function (table) {
table.foreign(['assetId']).references('assets.id')
table.unique('url')
}),
knex.raw(
'ALTER INDEX "walletAddresses_pkey" RENAME TO "paymentPointers_pkey"'
),
knex.raw(
'ALTER INDEX "walletAddresses_url_index" RENAME TO "paymentPointers_url_index"'
),
knex.raw(
'ALTER INDEX "walletaddresses_processat_index" RENAME TO "paymentpointers_processat_index"'
),
knex.raw(
'ALTER TABLE "paymentPointers" DROP CONSTRAINT "walletaddresses_url_unique"'
),
knex.raw(
'ALTER TABLE "paymentPointers" DROP CONSTRAINT "walletaddreses_assetid_foreign"'
),
knex.schema.renameTable('walletAddressKeys', 'paymentPointerKeys'),
knex.schema.alterTable('paymentPointerKeys', function (table) {
table.dropForeign(['walletAddressId'])
Expand Down

0 comments on commit b1bde3d

Please sign in to comment.