CREATE TABLE IF NOT EXISTS `wedding_gift_settings` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `invitation_id` BIGINT UNSIGNED NOT NULL COMMENT '-> invitations.id',
    `is_enabled` TINYINT(1) NOT NULL DEFAULT 1,
    `title` VARCHAR(150) NOT NULL DEFAULT 'Wedding Gift',
    `subtitle` TEXT NULL,
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_invitation` (`invitation_id`),
    CONSTRAINT `fk_wg_settings_invitation` FOREIGN KEY (`invitation_id`) REFERENCES `invitations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `wedding_gift_accounts` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `gift_setting_id` BIGINT UNSIGNED NOT NULL COMMENT '-> wedding_gift_settings.id',
    `provider_name` VARCHAR(100) NOT NULL COMMENT 'Bank/Wallet Name e.g. BCA',
    `account_number` VARCHAR(100) NOT NULL,
    `account_holder` VARCHAR(150) NOT NULL,
    `account_type` VARCHAR(50) NOT NULL DEFAULT 'bank_transfer' COMMENT 'bank_transfer, qris, etc',
    `is_active` TINYINT(1) NOT NULL DEFAULT 1,
    `sort_order` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    CONSTRAINT `fk_wg_accounts_setting` FOREIGN KEY (`gift_setting_id`) REFERENCES `wedding_gift_settings` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
