-- Rollback: Remove wallet, card replacement, tag tables and revert carrier, order changes
-- Created: 2026-01-13

-- Revert order table changes
ALTER TABLE tb_order DROP COLUMN IF EXISTS online_payment_amount;
ALTER TABLE tb_order DROP COLUMN IF EXISTS wallet_payment_amount;

-- Revert carrier table changes
DROP INDEX IF EXISTS idx_carrier_type_channel;
ALTER TABLE tb_carrier DROP COLUMN IF EXISTS channel_code;
ALTER TABLE tb_carrier DROP COLUMN IF EXISTS channel_name;
ALTER TABLE tb_carrier DROP COLUMN IF EXISTS carrier_type;

-- Drop tag tables
DROP INDEX IF EXISTS idx_resource_tag_unique;
DROP INDEX IF EXISTS idx_resource_tag_composite;
DROP INDEX IF EXISTS idx_resource_tag_tag;
DROP INDEX IF EXISTS idx_resource_tag_resource;
DROP TABLE IF EXISTS tb_resource_tag;

DROP INDEX IF EXISTS idx_tag_name;
DROP INDEX IF EXISTS idx_tag_usage;
DROP TABLE IF EXISTS tb_tag;

-- Drop card replacement table
DROP INDEX IF EXISTS idx_card_replacement_no;
DROP INDEX IF EXISTS idx_card_replacement_status;
DROP INDEX IF EXISTS idx_card_replacement_new_owner;
DROP INDEX IF EXISTS idx_card_replacement_old_owner;
DROP INDEX IF EXISTS idx_card_replacement_new_card;
DROP INDEX IF EXISTS idx_card_replacement_old_card;
DROP TABLE IF EXISTS tb_card_replacement_record;

-- Drop recharge record table
DROP INDEX IF EXISTS idx_recharge_no;
DROP INDEX IF EXISTS idx_recharge_status;
DROP INDEX IF EXISTS idx_recharge_user;
DROP TABLE IF EXISTS tb_recharge_record;

-- Drop wallet transaction table
DROP INDEX IF EXISTS idx_wallet_tx_ref;
DROP INDEX IF EXISTS idx_wallet_tx_user;
DROP INDEX IF EXISTS idx_wallet_tx_wallet;
DROP TABLE IF EXISTS tb_wallet_transaction;

-- Drop wallet table
DROP INDEX IF EXISTS idx_wallet_user_type_currency;
DROP INDEX IF EXISTS idx_wallet_status;
DROP INDEX IF EXISTS idx_wallet_user;
DROP TABLE IF EXISTS tb_wallet;
