Church Cashbook
Data Schema Manual
Manual home Return to Church Cashbook

Table: gift_aid_tx_flags

Flags and exception statuses used by the Gift Aid workflow for individual transactions.

Purpose

Stores a single, current “flag” for a transaction during Gift Aid processing — for example to mark a transaction as pending review, not eligible, or to be ignored.

Relationships

Columns

Indexes

Constraints

Operational notes / invariants

DDL

CREATE TABLE `gift_aid_tx_flags` (
  `id` int UNSIGNED NOT NULL,
  `church_id` int UNSIGNED NOT NULL,
  `transaction_id` int UNSIGNED NOT NULL,
  `flag_status` enum('PENDING','NOT_ELIGIBLE','IGNORE') NOT NULL,
  `note` varchar(255) DEFAULT NULL,
  `updated_by_user_id` int UNSIGNED DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

ALTER TABLE `gift_aid_tx_flags`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_tx` (`transaction_id`),
  ADD KEY `idx_church` (`church_id`),
  ADD KEY `idx_flag` (`flag_status`),
  ADD KEY `idx_updated_by` (`updated_by_user_id`);

ALTER TABLE `gift_aid_tx_flags`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `gift_aid_tx_flags`
  ADD CONSTRAINT `fk_ga_flags_church` FOREIGN KEY (`church_id`) REFERENCES `churches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ga_flags_tx` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_ga_flags_user` FOREIGN KEY (`updated_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;