mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix: Up Migrations
This commit is contained in:
parent
737859db89
commit
3a5ba17b6e
@ -28,7 +28,9 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
*/
|
||||
|
||||
// rename `state_user_id` to `user_id`
|
||||
await queryFn('ALTER TABLE `state_user_transactions` RENAME COLUMN state_user_id TO user_id;')
|
||||
await queryFn(
|
||||
'ALTER TABLE `state_user_transactions` CHANGE COLUMN state_user_id user_id int(10);',
|
||||
)
|
||||
// Create new `amount` column, with a temporary default of null
|
||||
await queryFn(
|
||||
'ALTER TABLE `state_user_transactions` ADD COLUMN `amount` bigint(20) DEFAULT NULL AFTER `transaction_type_id`;',
|
||||
|
||||
@ -11,23 +11,23 @@
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
// drop column `transaction_id`, it is not needed
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `transaction_id`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `transaction_id`;')
|
||||
// drop column `received`, it is a duplicate of balance_date
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `received`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `received`;')
|
||||
// drop column `tx_hash`, it is not needed
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `tx_hash`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `tx_hash`;')
|
||||
// drop column `signature`, it is not needed
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `signature`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `signature`;')
|
||||
// drop column `pubkey`, it is not needed
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `pubkey`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `pubkey`;')
|
||||
// drop column `creation_ident_hash`, it is not needed
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `creation_ident_hash`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `creation_ident_hash`;')
|
||||
|
||||
// rename `transaction_type_id` to `type_id`
|
||||
await queryFn('ALTER TABLE `transactions` RENAME COLUMN transaction_type_id TO type_id;')
|
||||
await queryFn('ALTER TABLE `transactions` CHANGE COLUMN transaction_type_id type_id int(10);')
|
||||
// rename `linked_state_user_transaction_id` to `linked_transaction_id`
|
||||
await queryFn(
|
||||
'ALTER TABLE `transactions` RENAME COLUMN linked_state_user_transaction_id TO linked_transaction_id;',
|
||||
'ALTER TABLE `transactions` CHANGE COLUMN linked_state_user_transaction_id linked_transaction_id int(10);',
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -13,35 +13,39 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
|
||||
// Delete columns
|
||||
|
||||
// delete column `amount`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `amount`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `amount`;')
|
||||
// delete column `send_sender_final_balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `send_sender_final_balance`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `send_sender_final_balance`;')
|
||||
// delete column `balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `balance`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `balance`;')
|
||||
// delete column `temp_dec_send_sender_final_balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `temp_dec_send_sender_final_balance`;')
|
||||
await queryFn(
|
||||
'ALTER TABLE `transactions` DROP COLUMN IF EXISTS `temp_dec_send_sender_final_balance`;',
|
||||
)
|
||||
// delete column `temp_dec_diff_send_sender_final_balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `temp_dec_diff_send_sender_final_balance`;')
|
||||
await queryFn(
|
||||
'ALTER TABLE `transactions` DROP COLUMN IF EXISTS `temp_dec_diff_send_sender_final_balance`;',
|
||||
)
|
||||
// delete column `temp_dec_old_balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `temp_dec_old_balance`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `temp_dec_old_balance`;')
|
||||
// delete column `temp_dec_diff_balance`
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN `temp_dec_diff_balance`;')
|
||||
await queryFn('ALTER TABLE `transactions` DROP COLUMN IF EXISTS `temp_dec_diff_balance`;')
|
||||
|
||||
// Rename columns
|
||||
|
||||
// rename column `dec_amount` to `amount`
|
||||
await queryFn('ALTER TABLE `transactions` RENAME COLUMN `dec_amount` to `amount`;')
|
||||
await queryFn('ALTER TABLE `transactions` CHANGE COLUMN `dec_amount` `amount` DECIMAL(40,20);')
|
||||
|
||||
// rename column `dec_balance` to `balance`
|
||||
await queryFn('ALTER TABLE `transactions` RENAME COLUMN `dec_balance` to `balance`;')
|
||||
await queryFn('ALTER TABLE `transactions` CHANGE COLUMN `dec_balance` `balance` DECIMAL(40,20);')
|
||||
|
||||
// rename column `dec_decay` to `decay`
|
||||
await queryFn('ALTER TABLE `transactions` RENAME COLUMN `dec_decay` to `decay`;')
|
||||
await queryFn('ALTER TABLE `transactions` CHANGE COLUMN `dec_decay` `decay` DECIMAL(40,20);')
|
||||
|
||||
// Drop tables
|
||||
|
||||
// drop `state_balances`
|
||||
await queryFn('DROP TABLE `state_balances`;')
|
||||
await queryFn('DROP TABLE IF EXISTS `state_balances`;')
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
// rename `amount` to `amount_bigint`
|
||||
await queryFn('ALTER TABLE `admin_pending_creations` RENAME COLUMN `amount` TO `amount_bigint`;')
|
||||
await queryFn(
|
||||
'ALTER TABLE `admin_pending_creations` CHANGE COLUMN `amount` `amount_bigint` bigint(20);',
|
||||
)
|
||||
// add `amount` (decimal)
|
||||
await queryFn(
|
||||
'ALTER TABLE `admin_pending_creations` ADD COLUMN `amount` DECIMAL(40,20) DEFAULT NULL AFTER `amount_bigint`;',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user