feat(old-items): complete reuse workflow and refine miniapp home
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
ALTER TABLE `files` MODIFY `business_type` ENUM('SERVICE_RECORD','PROJECT_COVER','ACTIVITY_COVER','CONTENT_COVER','OLD_ITEM_DONATION_IMAGE') NOT NULL;
|
||||
|
||||
CREATE TABLE `old_item_drop_off_points` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `public_id` CHAR(36) NOT NULL,
|
||||
`name` VARCHAR(120) NOT NULL, `region_text` VARCHAR(120) NOT NULL,
|
||||
`address_text` VARCHAR(300) NOT NULL, `opening_hours` VARCHAR(200) NOT NULL,
|
||||
`is_active` BOOLEAN NOT NULL DEFAULT true, `sort_order` INTEGER NOT NULL DEFAULT 0,
|
||||
`created_by` BIGINT UNSIGNED NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL, UNIQUE INDEX `old_item_drop_off_points_public_id_key` (`public_id`),
|
||||
INDEX `old_item_drop_off_points_active_sort_idx` (`is_active`,`sort_order`), PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_needs` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `public_id` CHAR(36) NOT NULL,
|
||||
`client_request_id` CHAR(36) NOT NULL, `request_fingerprint` CHAR(64) NOT NULL,
|
||||
`title` VARCHAR(160) NOT NULL, `category` ENUM('CLOTHING','BOOKS','HOUSEHOLD','SPORTS') NOT NULL,
|
||||
`region_text` VARCHAR(120) NOT NULL, `beneficiary_group` VARCHAR(160) NOT NULL, `description` TEXT NOT NULL,
|
||||
`requested_quantity` INTEGER UNSIGNED NOT NULL, `fulfilled_quantity` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
||||
`priority` INTEGER NOT NULL DEFAULT 0, `sort_order` INTEGER NOT NULL DEFAULT 0,
|
||||
`status` ENUM('DRAFT','PUBLISHED','FULFILLED','CLOSED') NOT NULL DEFAULT 'DRAFT',
|
||||
`revision` INTEGER UNSIGNED NOT NULL DEFAULT 1, `published_at` DATETIME(3) NULL,
|
||||
`created_by` BIGINT UNSIGNED NOT NULL, `updated_by` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updated_at` DATETIME(3) NOT NULL,
|
||||
UNIQUE INDEX `old_item_needs_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_needs_creator_request_key` (`created_by`,`client_request_id`),
|
||||
INDEX `old_item_needs_public_list_idx` (`status`,`category`,`priority`,`sort_order`), PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_need_status_history` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `need_id` BIGINT UNSIGNED NOT NULL,
|
||||
`request_id` CHAR(36) NOT NULL, `request_fingerprint` CHAR(64) NOT NULL,
|
||||
`from_status` ENUM('DRAFT','PUBLISHED','FULFILLED','CLOSED') NULL,
|
||||
`to_status` ENUM('DRAFT','PUBLISHED','FULFILLED','CLOSED') NOT NULL,
|
||||
`operator_user_id` BIGINT UNSIGNED NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_need_status_history_request_id_key` (`request_id`),
|
||||
INDEX `old_item_need_history_need_created_idx` (`need_id`,`created_at`), PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_donations` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `public_id` CHAR(36) NOT NULL, `donation_no` VARCHAR(32) NOT NULL,
|
||||
`donor_user_id` BIGINT UNSIGNED NOT NULL, `client_request_id` CHAR(36) NOT NULL, `request_fingerprint` CHAR(64) NOT NULL,
|
||||
`category` ENUM('CLOTHING','BOOKS','HOUSEHOLD','SPORTS') NOT NULL,
|
||||
`item_condition` ENUM('NEW','LIKE_NEW','GOOD','FAIR') NOT NULL, `quantity` INTEGER UNSIGNED NOT NULL,
|
||||
`description_encrypted` TEXT NOT NULL, `method` ENUM('PICKUP','DROP_OFF') NOT NULL,
|
||||
`contact_name_encrypted` VARCHAR(512) NOT NULL, `mobile_encrypted` VARCHAR(512) NOT NULL, `mobile_hash` CHAR(64) NOT NULL,
|
||||
`address_encrypted` TEXT NULL, `appointment_at` DATETIME(3) NULL, `drop_off_point_id` BIGINT UNSIGNED NULL,
|
||||
`target_need_id` BIGINT UNSIGNED NULL, `assigned_user_id` BIGINT UNSIGNED NULL,
|
||||
`rejection_reason_encrypted` TEXT NULL,
|
||||
`status` ENUM('SUBMITTED','REJECTED','WAITING_PICKUP','WAITING_DROP_OFF','RECEIVED','PROCESSING','COMPLETED','CANCELLED') NOT NULL DEFAULT 'SUBMITTED',
|
||||
`revision` INTEGER UNSIGNED NOT NULL DEFAULT 1, `assisted_people` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
||||
`received_at` DATETIME(3) NULL, `completed_at` DATETIME(3) NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updated_at` DATETIME(3) NOT NULL,
|
||||
UNIQUE INDEX `old_item_donations_public_id_key` (`public_id`), UNIQUE INDEX `old_item_donations_donation_no_key` (`donation_no`),
|
||||
UNIQUE INDEX `old_item_donations_donor_request_key` (`donor_user_id`,`client_request_id`),
|
||||
INDEX `old_item_donations_donor_status_created_idx` (`donor_user_id`,`status`,`created_at`),
|
||||
INDEX `old_item_donations_admin_list_idx` (`status`,`method`,`created_at`),
|
||||
INDEX `old_item_donations_need_status_idx` (`target_need_id`,`status`), PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_donation_status_history` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `donation_id` BIGINT UNSIGNED NOT NULL,
|
||||
`request_id` CHAR(36) NOT NULL, `request_fingerprint` CHAR(64) NOT NULL,
|
||||
`from_status` ENUM('SUBMITTED','REJECTED','WAITING_PICKUP','WAITING_DROP_OFF','RECEIVED','PROCESSING','COMPLETED','CANCELLED') NULL,
|
||||
`to_status` ENUM('SUBMITTED','REJECTED','WAITING_PICKUP','WAITING_DROP_OFF','RECEIVED','PROCESSING','COMPLETED','CANCELLED') NOT NULL,
|
||||
`note_encrypted` TEXT NULL, `operator_user_id` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_donation_status_history_request_id_key` (`request_id`),
|
||||
INDEX `old_item_donation_history_donation_created_idx` (`donation_id`,`created_at`), PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_donation_files` (
|
||||
`donation_id` BIGINT UNSIGNED NOT NULL, `file_id` BIGINT UNSIGNED NOT NULL,
|
||||
`sort_order` INTEGER NOT NULL DEFAULT 0, `attached_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
INDEX `old_item_donation_files_file_idx` (`file_id`), PRIMARY KEY (`donation_id`,`file_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `old_item_drop_off_points` ADD CONSTRAINT `old_item_drop_off_points_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_needs` ADD CONSTRAINT `old_item_needs_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_needs` ADD CONSTRAINT `old_item_needs_updated_by_fkey` FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_need_status_history` ADD CONSTRAINT `old_item_need_history_need_fkey` FOREIGN KEY (`need_id`) REFERENCES `old_item_needs`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_need_status_history` ADD CONSTRAINT `old_item_need_history_operator_fkey` FOREIGN KEY (`operator_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donations` ADD CONSTRAINT `old_item_donations_donor_fkey` FOREIGN KEY (`donor_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donations` ADD CONSTRAINT `old_item_donations_assignee_fkey` FOREIGN KEY (`assigned_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donations` ADD CONSTRAINT `old_item_donations_drop_off_point_fkey` FOREIGN KEY (`drop_off_point_id`) REFERENCES `old_item_drop_off_points`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donations` ADD CONSTRAINT `old_item_donations_target_need_fkey` FOREIGN KEY (`target_need_id`) REFERENCES `old_item_needs`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donation_status_history` ADD CONSTRAINT `old_item_donation_history_donation_fkey` FOREIGN KEY (`donation_id`) REFERENCES `old_item_donations`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donation_status_history` ADD CONSTRAINT `old_item_donation_history_operator_fkey` FOREIGN KEY (`operator_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donation_files` ADD CONSTRAINT `old_item_donation_files_donation_fkey` FOREIGN KEY (`donation_id`) REFERENCES `old_item_donations`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_donation_files` ADD CONSTRAINT `old_item_donation_files_file_fkey` FOREIGN KEY (`file_id`) REFERENCES `files`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO `permissions` (`code`,`name`,`description`) VALUES
|
||||
('old_items:read','查看旧物善用','查看旧物捐赠、需求与统计'),
|
||||
('old_items:manage','管理旧物善用','审核、分配并更新旧物捐赠状态'),
|
||||
('old_item_needs:manage','管理旧物需求','发布、编辑和下架物资需求');
|
||||
|
||||
INSERT INTO `role_permissions` (`role_id`,`permission_id`)
|
||||
SELECT r.id,p.id FROM `roles` r CROSS JOIN `permissions` p
|
||||
WHERE r.code IN ('ADMIN','SUPER_ADMIN') AND p.code IN ('old_items:read','old_items:manage','old_item_needs:manage');
|
||||
INSERT INTO `role_permissions` (`role_id`,`permission_id`)
|
||||
SELECT r.id,p.id FROM `roles` r CROSS JOIN `permissions` p
|
||||
WHERE r.code IN ('STAFF','PROJECT_MANAGER') AND p.code IN ('old_items:read','old_items:manage')
|
||||
ON DUPLICATE KEY UPDATE `role_id`=`role_id`;
|
||||
@@ -0,0 +1,89 @@
|
||||
CREATE TABLE `old_item_inventory_imports` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`client_request_id` CHAR(36) NOT NULL,
|
||||
`request_fingerprint` CHAR(64) NOT NULL,
|
||||
`original_filename_encrypted` VARCHAR(512) NOT NULL,
|
||||
`row_count` INTEGER UNSIGNED NOT NULL,
|
||||
`created_by` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_inventory_imports_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_inventory_import_creator_request_key` (`created_by`, `client_request_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_inventory_items` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`inventory_no` VARCHAR(32) NOT NULL,
|
||||
`source_donation_id` BIGINT UNSIGNED NULL,
|
||||
`import_id` BIGINT UNSIGNED NULL,
|
||||
`category` ENUM('CLOTHING','BOOKS','HOUSEHOLD','SPORTS') NOT NULL,
|
||||
`item_name` VARCHAR(160) NOT NULL,
|
||||
`quantity` INTEGER UNSIGNED NOT NULL,
|
||||
`unit` VARCHAR(20) NOT NULL DEFAULT '件',
|
||||
`storage_location` VARCHAR(160) NOT NULL,
|
||||
`status` ENUM('IN_STOCK','SORTED','DISINFECTED','OUTBOUND','DELIVERED') NOT NULL DEFAULT 'IN_STOCK',
|
||||
`target_need_id` BIGINT UNSIGNED NULL,
|
||||
`beneficiary_id` BIGINT UNSIGNED NULL,
|
||||
`destination_region` VARCHAR(120) NULL,
|
||||
`note_encrypted` TEXT NULL,
|
||||
`landing_at` DATETIME(3) NULL,
|
||||
`revision` INTEGER UNSIGNED NOT NULL DEFAULT 1,
|
||||
`created_by` BIGINT UNSIGNED NOT NULL,
|
||||
`updated_by` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
UNIQUE INDEX `old_item_inventory_items_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_inventory_items_inventory_no_key` (`inventory_no`),
|
||||
UNIQUE INDEX `old_item_inventory_items_source_donation_id_key` (`source_donation_id`),
|
||||
INDEX `old_item_inventory_status_category_created_idx` (`status`, `category`, `created_at`),
|
||||
INDEX `old_item_inventory_need_status_idx` (`target_need_id`, `status`),
|
||||
INDEX `old_item_inventory_beneficiary_status_idx` (`beneficiary_id`, `status`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_inventory_events` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`inventory_item_id` BIGINT UNSIGNED NOT NULL,
|
||||
`request_id` CHAR(36) NOT NULL,
|
||||
`request_fingerprint` CHAR(64) NOT NULL,
|
||||
`event_type` ENUM('INBOUND','SORTED','DISINFECTED','OUTBOUND','DELIVERED') NOT NULL,
|
||||
`from_status` ENUM('IN_STOCK','SORTED','DISINFECTED','OUTBOUND','DELIVERED') NULL,
|
||||
`to_status` ENUM('IN_STOCK','SORTED','DISINFECTED','OUTBOUND','DELIVERED') NOT NULL,
|
||||
`location_text` VARCHAR(160) NULL,
|
||||
`note_encrypted` TEXT NULL,
|
||||
`event_at` DATETIME(3) NOT NULL,
|
||||
`operator_user_id` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_inventory_events_request_id_key` (`request_id`),
|
||||
INDEX `old_item_inventory_events_item_event_idx` (`inventory_item_id`, `event_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `old_item_inventory_imports` ADD CONSTRAINT `old_item_inventory_imports_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_source_donation_fkey` FOREIGN KEY (`source_donation_id`) REFERENCES `old_item_donations`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_import_fkey` FOREIGN KEY (`import_id`) REFERENCES `old_item_inventory_imports`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_target_need_fkey` FOREIGN KEY (`target_need_id`) REFERENCES `old_item_needs`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_beneficiary_fkey` FOREIGN KEY (`beneficiary_id`) REFERENCES `beneficiary_profiles`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_items` ADD CONSTRAINT `old_item_inventory_items_updated_by_fkey` FOREIGN KEY (`updated_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_events` ADD CONSTRAINT `old_item_inventory_events_item_fkey` FOREIGN KEY (`inventory_item_id`) REFERENCES `old_item_inventory_items`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_inventory_events` ADD CONSTRAINT `old_item_inventory_events_operator_fkey` FOREIGN KEY (`operator_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO `permissions` (`code`, `name`, `description`) VALUES
|
||||
('old_item_inventory:read', '查看旧物台账', '查看旧物物资全流程台账'),
|
||||
('old_item_inventory:manage', '管理旧物台账', '入库并更新旧物物资流转状态'),
|
||||
('old_item_inventory:import', '导入旧物台账', '从标准 Excel 模板批量导入物资'),
|
||||
('old_item_inventory:export', '导出旧物台账', '导出和打印最小化旧物台账');
|
||||
|
||||
INSERT INTO `role_permissions` (`role_id`, `permission_id`)
|
||||
SELECT r.id, p.id FROM `roles` r CROSS JOIN `permissions` p
|
||||
WHERE r.code IN ('ADMIN','SUPER_ADMIN') AND p.code IN (
|
||||
'old_item_inventory:read','old_item_inventory:manage','old_item_inventory:import','old_item_inventory:export'
|
||||
);
|
||||
|
||||
INSERT INTO `role_permissions` (`role_id`, `permission_id`)
|
||||
SELECT r.id, p.id FROM `roles` r CROSS JOIN `permissions` p
|
||||
WHERE r.code IN ('STAFF','PROJECT_MANAGER') AND p.code IN ('old_item_inventory:read','old_item_inventory:manage')
|
||||
ON DUPLICATE KEY UPDATE `role_id` = `role_id`;
|
||||
@@ -0,0 +1,113 @@
|
||||
CREATE TABLE `old_item_reward_configs` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`client_request_id` CHAR(36) NOT NULL,
|
||||
`request_fingerprint` CHAR(64) NOT NULL,
|
||||
`version` INTEGER UNSIGNED NOT NULL,
|
||||
`active_key` VARCHAR(16) NULL,
|
||||
`certificate_title` VARCHAR(120) NOT NULL,
|
||||
`certificate_message` VARCHAR(1000) NOT NULL,
|
||||
`issuer_name` VARCHAR(120) NOT NULL,
|
||||
`legal_notice` VARCHAR(500) NOT NULL,
|
||||
`clothing_points` INTEGER UNSIGNED NOT NULL,
|
||||
`books_points` INTEGER UNSIGNED NOT NULL,
|
||||
`household_points` INTEGER UNSIGNED NOT NULL,
|
||||
`sports_points` INTEGER UNSIGNED NOT NULL,
|
||||
`max_points_per_donation` INTEGER UNSIGNED NOT NULL,
|
||||
`created_by` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_reward_configs_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_reward_configs_client_request_id_key` (`client_request_id`),
|
||||
UNIQUE INDEX `old_item_reward_configs_version_key` (`version`),
|
||||
UNIQUE INDEX `old_item_reward_configs_active_key_key` (`active_key`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_certificates` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`certificate_no` VARCHAR(40) NOT NULL,
|
||||
`donation_id` BIGINT UNSIGNED NOT NULL,
|
||||
`config_id` BIGINT UNSIGNED NULL,
|
||||
`issue_request_id` CHAR(36) NOT NULL,
|
||||
`issue_fingerprint` CHAR(64) NOT NULL,
|
||||
`active_key` VARCHAR(16) NULL,
|
||||
`status` ENUM('ISSUED','REVOKED') NOT NULL DEFAULT 'ISSUED',
|
||||
`recipient_name_encrypted` VARCHAR(512) NOT NULL,
|
||||
`title_snapshot` VARCHAR(120) NOT NULL,
|
||||
`message_snapshot` VARCHAR(1000) NOT NULL,
|
||||
`issuer_snapshot` VARCHAR(120) NOT NULL,
|
||||
`legal_notice_snapshot` VARCHAR(500) NOT NULL,
|
||||
`issued_by` BIGINT UNSIGNED NOT NULL,
|
||||
`issued_at` DATETIME(3) NOT NULL,
|
||||
`revoked_by` BIGINT UNSIGNED NULL,
|
||||
`revoked_request_id` CHAR(36) NULL,
|
||||
`revoked_fingerprint` CHAR(64) NULL,
|
||||
`revoke_reason_encrypted` TEXT NULL,
|
||||
`revoked_at` DATETIME(3) NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_certificates_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_certificates_certificate_no_key` (`certificate_no`),
|
||||
UNIQUE INDEX `old_item_certificates_issue_request_id_key` (`issue_request_id`),
|
||||
UNIQUE INDEX `old_item_certificates_revoked_request_id_key` (`revoked_request_id`),
|
||||
UNIQUE INDEX `old_item_certificates_donation_active_key` (`donation_id`, `active_key`),
|
||||
INDEX `old_item_certificates_donation_issued_idx` (`donation_id`, `issued_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_point_accounts` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`user_id` BIGINT UNSIGNED NOT NULL,
|
||||
`balance` INTEGER UNSIGNED NOT NULL DEFAULT 0,
|
||||
`revision` INTEGER UNSIGNED NOT NULL DEFAULT 1,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL,
|
||||
UNIQUE INDEX `old_item_point_accounts_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_point_accounts_user_id_key` (`user_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `old_item_point_entries` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`public_id` CHAR(36) NOT NULL,
|
||||
`account_id` BIGINT UNSIGNED NOT NULL,
|
||||
`user_id` BIGINT UNSIGNED NOT NULL,
|
||||
`donation_id` BIGINT UNSIGNED NULL,
|
||||
`config_id` BIGINT UNSIGNED NULL,
|
||||
`request_id` CHAR(36) NOT NULL,
|
||||
`request_fingerprint` CHAR(64) NOT NULL,
|
||||
`source_key` VARCHAR(100) NOT NULL,
|
||||
`entry_type` ENUM('EARNED','ADJUSTMENT') NOT NULL,
|
||||
`points_delta` INTEGER NOT NULL,
|
||||
`balance_after` INTEGER UNSIGNED NOT NULL,
|
||||
`note_encrypted` TEXT NULL,
|
||||
`operator_user_id` BIGINT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
UNIQUE INDEX `old_item_point_entries_public_id_key` (`public_id`),
|
||||
UNIQUE INDEX `old_item_point_entries_request_id_key` (`request_id`),
|
||||
UNIQUE INDEX `old_item_point_entries_source_key_key` (`source_key`),
|
||||
INDEX `old_item_point_entries_user_created_idx` (`user_id`, `created_at`),
|
||||
INDEX `old_item_point_entries_donation_idx` (`donation_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `old_item_reward_configs` ADD CONSTRAINT `old_item_reward_configs_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_certificates` ADD CONSTRAINT `old_item_certificates_donation_fkey` FOREIGN KEY (`donation_id`) REFERENCES `old_item_donations`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_certificates` ADD CONSTRAINT `old_item_certificates_config_fkey` FOREIGN KEY (`config_id`) REFERENCES `old_item_reward_configs`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_certificates` ADD CONSTRAINT `old_item_certificates_issued_by_fkey` FOREIGN KEY (`issued_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_certificates` ADD CONSTRAINT `old_item_certificates_revoked_by_fkey` FOREIGN KEY (`revoked_by`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_accounts` ADD CONSTRAINT `old_item_point_accounts_user_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_entries` ADD CONSTRAINT `old_item_point_entries_account_fkey` FOREIGN KEY (`account_id`) REFERENCES `old_item_point_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_entries` ADD CONSTRAINT `old_item_point_entries_user_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_entries` ADD CONSTRAINT `old_item_point_entries_donation_fkey` FOREIGN KEY (`donation_id`) REFERENCES `old_item_donations`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_entries` ADD CONSTRAINT `old_item_point_entries_config_fkey` FOREIGN KEY (`config_id`) REFERENCES `old_item_reward_configs`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `old_item_point_entries` ADD CONSTRAINT `old_item_point_entries_operator_fkey` FOREIGN KEY (`operator_user_id`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO `permissions` (`code`, `name`, `description`) VALUES
|
||||
('old_item_rewards:read', '查看旧物证书积分', '查看旧物善用证书、积分账户和规则'),
|
||||
('old_item_rewards:manage', '管理旧物证书积分', '配置规则、补发撤销证书和调整公益积分');
|
||||
|
||||
INSERT INTO `role_permissions` (`role_id`, `permission_id`)
|
||||
SELECT r.id, p.id FROM `roles` r CROSS JOIN `permissions` p
|
||||
WHERE r.code IN ('ADMIN','SUPER_ADMIN') AND p.code IN ('old_item_rewards:read','old_item_rewards:manage');
|
||||
+529
-133
@@ -153,6 +153,70 @@ enum FileBusinessType {
|
||||
PROJECT_COVER
|
||||
ACTIVITY_COVER
|
||||
CONTENT_COVER
|
||||
OLD_ITEM_DONATION_IMAGE
|
||||
}
|
||||
|
||||
enum OldItemCategory {
|
||||
CLOTHING
|
||||
BOOKS
|
||||
HOUSEHOLD
|
||||
SPORTS
|
||||
}
|
||||
|
||||
enum OldItemCondition {
|
||||
NEW
|
||||
LIKE_NEW
|
||||
GOOD
|
||||
FAIR
|
||||
}
|
||||
|
||||
enum OldItemDonationMethod {
|
||||
PICKUP
|
||||
DROP_OFF
|
||||
}
|
||||
|
||||
enum OldItemDonationStatus {
|
||||
SUBMITTED
|
||||
REJECTED
|
||||
WAITING_PICKUP
|
||||
WAITING_DROP_OFF
|
||||
RECEIVED
|
||||
PROCESSING
|
||||
COMPLETED
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum OldItemNeedStatus {
|
||||
DRAFT
|
||||
PUBLISHED
|
||||
FULFILLED
|
||||
CLOSED
|
||||
}
|
||||
|
||||
enum OldItemInventoryStatus {
|
||||
IN_STOCK
|
||||
SORTED
|
||||
DISINFECTED
|
||||
OUTBOUND
|
||||
DELIVERED
|
||||
}
|
||||
|
||||
enum OldItemInventoryEventType {
|
||||
INBOUND
|
||||
SORTED
|
||||
DISINFECTED
|
||||
OUTBOUND
|
||||
DELIVERED
|
||||
}
|
||||
|
||||
enum OldItemCertificateStatus {
|
||||
ISSUED
|
||||
REVOKED
|
||||
}
|
||||
|
||||
enum OldItemPointEntryType {
|
||||
EARNED
|
||||
ADJUSTMENT
|
||||
}
|
||||
|
||||
enum ContentPostType {
|
||||
@@ -261,70 +325,87 @@ enum FollowUpSource {
|
||||
}
|
||||
|
||||
model User {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
status UserStatus @default(ACTIVE)
|
||||
userType UserType @map("user_type")
|
||||
mobileEncrypted String? @map("mobile_encrypted") @db.VarChar(512)
|
||||
mobileHash String? @unique @map("mobile_hash") @db.Char(64)
|
||||
nickname String? @db.VarChar(100)
|
||||
avatarUrl String? @map("avatar_url") @db.VarChar(512)
|
||||
lastLoginAt DateTime? @map("last_login_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
wechatIdentities WechatIdentity[]
|
||||
staffProfile StaffProfile?
|
||||
adminCredential AdminCredential?
|
||||
sessions AuthSession[]
|
||||
userRoles UserRole[]
|
||||
auditLogs AuditLog[] @relation("AuditActor")
|
||||
assignedRoles UserRole[] @relation("UserRoleAssigner")
|
||||
serviceApplications ServiceApplication[] @relation("ApplicationApplicant")
|
||||
applicationStatusChanges ServiceApplicationStatusHistory[] @relation("ApplicationStatusOperator")
|
||||
consents Consent[]
|
||||
createdBeneficiaries BeneficiaryProfile[] @relation("BeneficiaryCreator")
|
||||
updatedBeneficiaries BeneficiaryProfile[] @relation("BeneficiaryUpdater")
|
||||
ownedServiceCases ServiceCase[] @relation("CaseOwner")
|
||||
createdServiceCases ServiceCase[] @relation("CaseCreator")
|
||||
updatedServiceCases ServiceCase[] @relation("CaseUpdater")
|
||||
caseAssignments CaseAssignee[]
|
||||
caseStatusChanges ServiceCaseStatusHistory[] @relation("CaseStatusOperator")
|
||||
createdServiceRecords ServiceRecord[] @relation("ServiceRecordCreator")
|
||||
updatedServiceRecords ServiceRecord[] @relation("ServiceRecordUpdater")
|
||||
uploadedFiles File[] @relation("FileUploader")
|
||||
assignedBeneficiaryTags BeneficiaryTag[] @relation("BeneficiaryTagAssigner")
|
||||
assignedCaseMembers CaseAssignee[] @relation("CaseAssigneeAssigner")
|
||||
revisedServiceRecords ServiceRecordRevision[] @relation("ServiceRecordReviser")
|
||||
ownedFollowUpTasks FollowUpTask[] @relation("FollowUpOwner")
|
||||
createdFollowUpTasks FollowUpTask[] @relation("FollowUpCreator")
|
||||
updatedFollowUpTasks FollowUpTask[] @relation("FollowUpUpdater")
|
||||
followUpStatusChanges FollowUpStatusHistory[] @relation("FollowUpStatusOperator")
|
||||
volunteerProfile Volunteer?
|
||||
reviewedVolunteers Volunteer[] @relation("VolunteerReviewer")
|
||||
createdVolunteers Volunteer[] @relation("VolunteerCreator")
|
||||
updatedVolunteers Volunteer[] @relation("VolunteerUpdater")
|
||||
volunteerStatusChanges VolunteerStatusHistory[] @relation("VolunteerStatusOperator")
|
||||
managedProjects Project[] @relation("ProjectManager")
|
||||
createdProjects Project[] @relation("ProjectCreator")
|
||||
updatedProjects Project[] @relation("ProjectUpdater")
|
||||
projectStatusChanges ProjectStatusHistory[] @relation("ProjectStatusOperator")
|
||||
createdActivities Activity[] @relation("ActivityCreator")
|
||||
updatedActivities Activity[] @relation("ActivityUpdater")
|
||||
activityStatusChanges ActivityStatusHistory[] @relation("ActivityStatusOperator")
|
||||
activityRegistrations ActivityRegistration[] @relation("ActivityRegistrationUser")
|
||||
reviewedRegistrations ActivityRegistration[] @relation("RegistrationReviewer")
|
||||
checkedInRegistrations ActivityRegistration[] @relation("RegistrationCheckInOperator")
|
||||
recordedServiceMinutes ActivityRegistration[] @relation("RegistrationMinutesOperator")
|
||||
registrationChanges ActivityRegistrationHistory[] @relation("RegistrationHistoryOperator")
|
||||
createdContentPosts ContentPost[] @relation("ContentCreator")
|
||||
updatedContentPosts ContentPost[] @relation("ContentUpdater")
|
||||
reviewedContentPosts ContentPost[] @relation("ContentReviewer")
|
||||
contentStatusChanges ContentPostStatusHistory[] @relation("ContentStatusOperator")
|
||||
notifications Notification[]
|
||||
notificationPreferences NotificationPreference[]
|
||||
createdFinancialDisclosures FinancialDisclosure[] @relation("FinancialDisclosureCreator")
|
||||
updatedFinancialDisclosures FinancialDisclosure[] @relation("FinancialDisclosureUpdater")
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
status UserStatus @default(ACTIVE)
|
||||
userType UserType @map("user_type")
|
||||
mobileEncrypted String? @map("mobile_encrypted") @db.VarChar(512)
|
||||
mobileHash String? @unique @map("mobile_hash") @db.Char(64)
|
||||
nickname String? @db.VarChar(100)
|
||||
avatarUrl String? @map("avatar_url") @db.VarChar(512)
|
||||
lastLoginAt DateTime? @map("last_login_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
wechatIdentities WechatIdentity[]
|
||||
staffProfile StaffProfile?
|
||||
adminCredential AdminCredential?
|
||||
sessions AuthSession[]
|
||||
userRoles UserRole[]
|
||||
auditLogs AuditLog[] @relation("AuditActor")
|
||||
assignedRoles UserRole[] @relation("UserRoleAssigner")
|
||||
serviceApplications ServiceApplication[] @relation("ApplicationApplicant")
|
||||
applicationStatusChanges ServiceApplicationStatusHistory[] @relation("ApplicationStatusOperator")
|
||||
consents Consent[]
|
||||
createdBeneficiaries BeneficiaryProfile[] @relation("BeneficiaryCreator")
|
||||
updatedBeneficiaries BeneficiaryProfile[] @relation("BeneficiaryUpdater")
|
||||
ownedServiceCases ServiceCase[] @relation("CaseOwner")
|
||||
createdServiceCases ServiceCase[] @relation("CaseCreator")
|
||||
updatedServiceCases ServiceCase[] @relation("CaseUpdater")
|
||||
caseAssignments CaseAssignee[]
|
||||
caseStatusChanges ServiceCaseStatusHistory[] @relation("CaseStatusOperator")
|
||||
createdServiceRecords ServiceRecord[] @relation("ServiceRecordCreator")
|
||||
updatedServiceRecords ServiceRecord[] @relation("ServiceRecordUpdater")
|
||||
uploadedFiles File[] @relation("FileUploader")
|
||||
assignedBeneficiaryTags BeneficiaryTag[] @relation("BeneficiaryTagAssigner")
|
||||
assignedCaseMembers CaseAssignee[] @relation("CaseAssigneeAssigner")
|
||||
revisedServiceRecords ServiceRecordRevision[] @relation("ServiceRecordReviser")
|
||||
ownedFollowUpTasks FollowUpTask[] @relation("FollowUpOwner")
|
||||
createdFollowUpTasks FollowUpTask[] @relation("FollowUpCreator")
|
||||
updatedFollowUpTasks FollowUpTask[] @relation("FollowUpUpdater")
|
||||
followUpStatusChanges FollowUpStatusHistory[] @relation("FollowUpStatusOperator")
|
||||
volunteerProfile Volunteer?
|
||||
reviewedVolunteers Volunteer[] @relation("VolunteerReviewer")
|
||||
createdVolunteers Volunteer[] @relation("VolunteerCreator")
|
||||
updatedVolunteers Volunteer[] @relation("VolunteerUpdater")
|
||||
volunteerStatusChanges VolunteerStatusHistory[] @relation("VolunteerStatusOperator")
|
||||
managedProjects Project[] @relation("ProjectManager")
|
||||
createdProjects Project[] @relation("ProjectCreator")
|
||||
updatedProjects Project[] @relation("ProjectUpdater")
|
||||
projectStatusChanges ProjectStatusHistory[] @relation("ProjectStatusOperator")
|
||||
createdActivities Activity[] @relation("ActivityCreator")
|
||||
updatedActivities Activity[] @relation("ActivityUpdater")
|
||||
activityStatusChanges ActivityStatusHistory[] @relation("ActivityStatusOperator")
|
||||
activityRegistrations ActivityRegistration[] @relation("ActivityRegistrationUser")
|
||||
reviewedRegistrations ActivityRegistration[] @relation("RegistrationReviewer")
|
||||
checkedInRegistrations ActivityRegistration[] @relation("RegistrationCheckInOperator")
|
||||
recordedServiceMinutes ActivityRegistration[] @relation("RegistrationMinutesOperator")
|
||||
registrationChanges ActivityRegistrationHistory[] @relation("RegistrationHistoryOperator")
|
||||
createdContentPosts ContentPost[] @relation("ContentCreator")
|
||||
updatedContentPosts ContentPost[] @relation("ContentUpdater")
|
||||
reviewedContentPosts ContentPost[] @relation("ContentReviewer")
|
||||
contentStatusChanges ContentPostStatusHistory[] @relation("ContentStatusOperator")
|
||||
notifications Notification[]
|
||||
notificationPreferences NotificationPreference[]
|
||||
createdFinancialDisclosures FinancialDisclosure[] @relation("FinancialDisclosureCreator")
|
||||
updatedFinancialDisclosures FinancialDisclosure[] @relation("FinancialDisclosureUpdater")
|
||||
financialDisclosureStatusChanges FinancialDisclosureStatusHistory[] @relation("FinancialDisclosureStatusOperator")
|
||||
oldItemDonations OldItemDonation[] @relation("OldItemDonor")
|
||||
assignedOldItemDonations OldItemDonation[] @relation("OldItemAssignee")
|
||||
oldItemDonationStatusChanges OldItemDonationStatusHistory[] @relation("OldItemDonationStatusOperator")
|
||||
createdOldItemNeeds OldItemNeed[] @relation("OldItemNeedCreator")
|
||||
updatedOldItemNeeds OldItemNeed[] @relation("OldItemNeedUpdater")
|
||||
oldItemNeedStatusChanges OldItemNeedStatusHistory[] @relation("OldItemNeedStatusOperator")
|
||||
createdOldItemDropOffPoints OldItemDropOffPoint[] @relation("OldItemDropOffPointCreator")
|
||||
createdOldItemInventoryItems OldItemInventoryItem[] @relation("OldItemInventoryCreator")
|
||||
updatedOldItemInventoryItems OldItemInventoryItem[] @relation("OldItemInventoryUpdater")
|
||||
oldItemInventoryEvents OldItemInventoryEvent[] @relation("OldItemInventoryEventOperator")
|
||||
oldItemInventoryImports OldItemInventoryImport[] @relation("OldItemInventoryImportCreator")
|
||||
createdOldItemRewardConfigs OldItemRewardConfig[] @relation("OldItemRewardConfigCreator")
|
||||
issuedOldItemCertificates OldItemCertificate[] @relation("OldItemCertificateIssuer")
|
||||
revokedOldItemCertificates OldItemCertificate[] @relation("OldItemCertificateRevoker")
|
||||
oldItemPointAccount OldItemPointAccount?
|
||||
oldItemPointEntries OldItemPointEntry[] @relation("OldItemPointOwner")
|
||||
operatedOldItemPointEntries OldItemPointEntry[] @relation("OldItemPointOperator")
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -552,27 +633,27 @@ model ServiceApplicationStatusHistory {
|
||||
}
|
||||
|
||||
model BeneficiaryProfile {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
displayNameEncrypted String @map("display_name_encrypted") @db.VarChar(512)
|
||||
displayNameHash String @map("display_name_hash") @db.Char(64)
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
displayNameEncrypted String @map("display_name_encrypted") @db.VarChar(512)
|
||||
displayNameHash String @map("display_name_hash") @db.Char(64)
|
||||
gender BeneficiaryGender?
|
||||
birthYear Int? @map("birth_year") @db.UnsignedSmallInt
|
||||
mobileEncrypted String? @map("mobile_encrypted") @db.VarChar(512)
|
||||
mobileHash String? @map("mobile_hash") @db.Char(64)
|
||||
regionCode String @map("region_code") @db.VarChar(100)
|
||||
addressDetailEncrypted String? @map("address_detail_encrypted") @db.VarChar(1024)
|
||||
primaryCategory ServiceCategory @map("primary_category")
|
||||
keyCareFlag Boolean @default(false) @map("key_care_flag")
|
||||
isMinor Boolean @default(false) @map("is_minor")
|
||||
status BeneficiaryStatus @default(ACTIVE)
|
||||
notesEncrypted String? @map("notes_encrypted") @db.Text
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("BeneficiaryCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("BeneficiaryUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
birthYear Int? @map("birth_year") @db.UnsignedSmallInt
|
||||
mobileEncrypted String? @map("mobile_encrypted") @db.VarChar(512)
|
||||
mobileHash String? @map("mobile_hash") @db.Char(64)
|
||||
regionCode String @map("region_code") @db.VarChar(100)
|
||||
addressDetailEncrypted String? @map("address_detail_encrypted") @db.VarChar(1024)
|
||||
primaryCategory ServiceCategory @map("primary_category")
|
||||
keyCareFlag Boolean @default(false) @map("key_care_flag")
|
||||
isMinor Boolean @default(false) @map("is_minor")
|
||||
status BeneficiaryStatus @default(ACTIVE)
|
||||
notesEncrypted String? @map("notes_encrypted") @db.Text
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("BeneficiaryCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("BeneficiaryUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
contacts BeneficiaryContact[]
|
||||
beneficiaryTags BeneficiaryTag[]
|
||||
applications ServiceApplication[]
|
||||
@@ -580,6 +661,7 @@ model BeneficiaryProfile {
|
||||
serviceRecords ServiceRecord[]
|
||||
consents Consent[]
|
||||
followUpTasks FollowUpTask[]
|
||||
oldItemInventoryItems OldItemInventoryItem[]
|
||||
|
||||
@@index([displayNameHash], map: "beneficiary_profiles_display_name_hash_idx")
|
||||
@@index([mobileHash], map: "beneficiary_profiles_mobile_hash_idx")
|
||||
@@ -769,29 +851,30 @@ model ServiceRecordRevision {
|
||||
}
|
||||
|
||||
model File {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
caseId BigInt? @map("case_id") @db.UnsignedBigInt
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
storageProvider String @map("storage_provider") @db.VarChar(50)
|
||||
bucket String @db.VarChar(255)
|
||||
objectKey String @unique @map("object_key") @db.VarChar(512)
|
||||
originalFilenameEncrypted String @map("original_filename_encrypted") @db.VarChar(1024)
|
||||
mimeType String @map("mime_type") @db.VarChar(100)
|
||||
size BigInt @db.UnsignedBigInt
|
||||
sha256 String? @db.Char(64)
|
||||
businessType FileBusinessType @map("business_type")
|
||||
uploaderUserId BigInt @map("uploader_user_id") @db.UnsignedBigInt
|
||||
status FileStatus @default(UPLOAD_PENDING)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
serviceCase ServiceCase? @relation(fields: [caseId], references: [id], onDelete: Restrict)
|
||||
uploader User @relation("FileUploader", fields: [uploaderUserId], references: [id], onDelete: Restrict)
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
caseId BigInt? @map("case_id") @db.UnsignedBigInt
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
storageProvider String @map("storage_provider") @db.VarChar(50)
|
||||
bucket String @db.VarChar(255)
|
||||
objectKey String @unique @map("object_key") @db.VarChar(512)
|
||||
originalFilenameEncrypted String @map("original_filename_encrypted") @db.VarChar(1024)
|
||||
mimeType String @map("mime_type") @db.VarChar(100)
|
||||
size BigInt @db.UnsignedBigInt
|
||||
sha256 String? @db.Char(64)
|
||||
businessType FileBusinessType @map("business_type")
|
||||
uploaderUserId BigInt @map("uploader_user_id") @db.UnsignedBigInt
|
||||
status FileStatus @default(UPLOAD_PENDING)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
serviceCase ServiceCase? @relation(fields: [caseId], references: [id], onDelete: Restrict)
|
||||
uploader User @relation("FileUploader", fields: [uploaderUserId], references: [id], onDelete: Restrict)
|
||||
serviceRecords ServiceRecordFile[]
|
||||
projectCover Project? @relation("ProjectCover")
|
||||
activityCover Activity? @relation("ActivityCover")
|
||||
contentCover ContentPost? @relation("ContentCover")
|
||||
projectCover Project? @relation("ProjectCover")
|
||||
activityCover Activity? @relation("ActivityCover")
|
||||
contentCover ContentPost? @relation("ContentCover")
|
||||
oldItemDonations OldItemDonationFile[]
|
||||
|
||||
@@unique([uploaderUserId, clientRequestId], map: "files_uploader_client_request_key")
|
||||
@@index([caseId, status, createdAt], map: "files_case_status_created_at_idx")
|
||||
@@ -799,6 +882,319 @@ model File {
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model OldItemDropOffPoint {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
name String @db.VarChar(120)
|
||||
regionText String @map("region_text") @db.VarChar(120)
|
||||
addressText String @map("address_text") @db.VarChar(300)
|
||||
openingHours String @map("opening_hours") @db.VarChar(200)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("OldItemDropOffPointCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
donations OldItemDonation[]
|
||||
|
||||
@@index([isActive, sortOrder], map: "old_item_drop_off_points_active_sort_idx")
|
||||
@@map("old_item_drop_off_points")
|
||||
}
|
||||
|
||||
model OldItemNeed {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
title String @db.VarChar(160)
|
||||
category OldItemCategory
|
||||
regionText String @map("region_text") @db.VarChar(120)
|
||||
beneficiaryGroup String @map("beneficiary_group") @db.VarChar(160)
|
||||
description String @db.Text
|
||||
requestedQuantity Int @map("requested_quantity") @db.UnsignedInt
|
||||
fulfilledQuantity Int @default(0) @map("fulfilled_quantity") @db.UnsignedInt
|
||||
priority Int @default(0)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
status OldItemNeedStatus @default(DRAFT)
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
publishedAt DateTime? @map("published_at") @db.DateTime(3)
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("OldItemNeedCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("OldItemNeedUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
donations OldItemDonation[]
|
||||
history OldItemNeedStatusHistory[]
|
||||
inventoryItems OldItemInventoryItem[]
|
||||
|
||||
@@unique([createdById, clientRequestId], map: "old_item_needs_creator_request_key")
|
||||
@@index([status, category, priority, sortOrder], map: "old_item_needs_public_list_idx")
|
||||
@@map("old_item_needs")
|
||||
}
|
||||
|
||||
model OldItemNeedStatusHistory {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
needId BigInt @map("need_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
fromStatus OldItemNeedStatus? @map("from_status")
|
||||
toStatus OldItemNeedStatus @map("to_status")
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
need OldItemNeed @relation(fields: [needId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("OldItemNeedStatusOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([needId, createdAt], map: "old_item_need_history_need_created_idx")
|
||||
@@map("old_item_need_status_history")
|
||||
}
|
||||
|
||||
model OldItemDonation {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
donationNo String @unique @map("donation_no") @db.VarChar(32)
|
||||
donorUserId BigInt @map("donor_user_id") @db.UnsignedBigInt
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
category OldItemCategory
|
||||
itemCondition OldItemCondition @map("item_condition")
|
||||
quantity Int @db.UnsignedInt
|
||||
descriptionEncrypted String @map("description_encrypted") @db.Text
|
||||
method OldItemDonationMethod
|
||||
contactNameEncrypted String @map("contact_name_encrypted") @db.VarChar(512)
|
||||
mobileEncrypted String @map("mobile_encrypted") @db.VarChar(512)
|
||||
mobileHash String @map("mobile_hash") @db.Char(64)
|
||||
addressEncrypted String? @map("address_encrypted") @db.Text
|
||||
appointmentAt DateTime? @map("appointment_at") @db.DateTime(3)
|
||||
dropOffPointId BigInt? @map("drop_off_point_id") @db.UnsignedBigInt
|
||||
targetNeedId BigInt? @map("target_need_id") @db.UnsignedBigInt
|
||||
assignedUserId BigInt? @map("assigned_user_id") @db.UnsignedBigInt
|
||||
rejectionReasonEncrypted String? @map("rejection_reason_encrypted") @db.Text
|
||||
status OldItemDonationStatus @default(SUBMITTED)
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
assistedPeople Int @default(0) @map("assisted_people") @db.UnsignedInt
|
||||
receivedAt DateTime? @map("received_at") @db.DateTime(3)
|
||||
completedAt DateTime? @map("completed_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
donor User @relation("OldItemDonor", fields: [donorUserId], references: [id], onDelete: Restrict)
|
||||
assignee User? @relation("OldItemAssignee", fields: [assignedUserId], references: [id], onDelete: Restrict)
|
||||
dropOffPoint OldItemDropOffPoint? @relation(fields: [dropOffPointId], references: [id], onDelete: Restrict)
|
||||
targetNeed OldItemNeed? @relation(fields: [targetNeedId], references: [id], onDelete: Restrict)
|
||||
history OldItemDonationStatusHistory[]
|
||||
files OldItemDonationFile[]
|
||||
inventoryItems OldItemInventoryItem[]
|
||||
certificates OldItemCertificate[]
|
||||
pointEntries OldItemPointEntry[]
|
||||
|
||||
@@unique([donorUserId, clientRequestId], map: "old_item_donations_donor_request_key")
|
||||
@@index([donorUserId, status, createdAt], map: "old_item_donations_donor_status_created_idx")
|
||||
@@index([status, method, createdAt], map: "old_item_donations_admin_list_idx")
|
||||
@@index([targetNeedId, status], map: "old_item_donations_need_status_idx")
|
||||
@@map("old_item_donations")
|
||||
}
|
||||
|
||||
model OldItemRewardConfig {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
clientRequestId String @unique @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
version Int @unique @db.UnsignedInt
|
||||
activeKey String? @unique @map("active_key") @db.VarChar(16)
|
||||
certificateTitle String @map("certificate_title") @db.VarChar(120)
|
||||
certificateMessage String @map("certificate_message") @db.VarChar(1000)
|
||||
issuerName String @map("issuer_name") @db.VarChar(120)
|
||||
legalNotice String @map("legal_notice") @db.VarChar(500)
|
||||
clothingPoints Int @map("clothing_points") @db.UnsignedInt
|
||||
booksPoints Int @map("books_points") @db.UnsignedInt
|
||||
householdPoints Int @map("household_points") @db.UnsignedInt
|
||||
sportsPoints Int @map("sports_points") @db.UnsignedInt
|
||||
maxPointsPerDonation Int @map("max_points_per_donation") @db.UnsignedInt
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
creator User @relation("OldItemRewardConfigCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
certificates OldItemCertificate[]
|
||||
pointEntries OldItemPointEntry[]
|
||||
|
||||
@@map("old_item_reward_configs")
|
||||
}
|
||||
|
||||
model OldItemCertificate {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
certificateNo String @unique @map("certificate_no") @db.VarChar(40)
|
||||
donationId BigInt @map("donation_id") @db.UnsignedBigInt
|
||||
configId BigInt? @map("config_id") @db.UnsignedBigInt
|
||||
issueRequestId String @unique @map("issue_request_id") @db.Char(36)
|
||||
issueFingerprint String @map("issue_fingerprint") @db.Char(64)
|
||||
activeKey String? @map("active_key") @db.VarChar(16)
|
||||
status OldItemCertificateStatus @default(ISSUED)
|
||||
recipientNameEncrypted String @map("recipient_name_encrypted") @db.VarChar(512)
|
||||
titleSnapshot String @map("title_snapshot") @db.VarChar(120)
|
||||
messageSnapshot String @map("message_snapshot") @db.VarChar(1000)
|
||||
issuerSnapshot String @map("issuer_snapshot") @db.VarChar(120)
|
||||
legalNoticeSnapshot String @map("legal_notice_snapshot") @db.VarChar(500)
|
||||
issuedById BigInt @map("issued_by") @db.UnsignedBigInt
|
||||
issuedAt DateTime @map("issued_at") @db.DateTime(3)
|
||||
revokedById BigInt? @map("revoked_by") @db.UnsignedBigInt
|
||||
revokedRequestId String? @unique @map("revoked_request_id") @db.Char(36)
|
||||
revokedFingerprint String? @map("revoked_fingerprint") @db.Char(64)
|
||||
revokeReasonEncrypted String? @map("revoke_reason_encrypted") @db.Text
|
||||
revokedAt DateTime? @map("revoked_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
donation OldItemDonation @relation(fields: [donationId], references: [id], onDelete: Restrict)
|
||||
config OldItemRewardConfig? @relation(fields: [configId], references: [id], onDelete: Restrict)
|
||||
issuer User @relation("OldItemCertificateIssuer", fields: [issuedById], references: [id], onDelete: Restrict)
|
||||
revoker User? @relation("OldItemCertificateRevoker", fields: [revokedById], references: [id], onDelete: Restrict)
|
||||
|
||||
@@unique([donationId, activeKey], map: "old_item_certificates_donation_active_key")
|
||||
@@index([donationId, issuedAt], map: "old_item_certificates_donation_issued_idx")
|
||||
@@map("old_item_certificates")
|
||||
}
|
||||
|
||||
model OldItemPointAccount {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
userId BigInt @unique @map("user_id") @db.UnsignedBigInt
|
||||
balance Int @default(0) @db.UnsignedInt
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
||||
entries OldItemPointEntry[]
|
||||
|
||||
@@map("old_item_point_accounts")
|
||||
}
|
||||
|
||||
model OldItemPointEntry {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
accountId BigInt @map("account_id") @db.UnsignedBigInt
|
||||
userId BigInt @map("user_id") @db.UnsignedBigInt
|
||||
donationId BigInt? @map("donation_id") @db.UnsignedBigInt
|
||||
configId BigInt? @map("config_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
sourceKey String @unique @map("source_key") @db.VarChar(100)
|
||||
entryType OldItemPointEntryType @map("entry_type")
|
||||
pointsDelta Int @map("points_delta")
|
||||
balanceAfter Int @map("balance_after") @db.UnsignedInt
|
||||
noteEncrypted String? @map("note_encrypted") @db.Text
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
account OldItemPointAccount @relation(fields: [accountId], references: [id], onDelete: Restrict)
|
||||
user User @relation("OldItemPointOwner", fields: [userId], references: [id], onDelete: Restrict)
|
||||
donation OldItemDonation? @relation(fields: [donationId], references: [id], onDelete: Restrict)
|
||||
config OldItemRewardConfig? @relation(fields: [configId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("OldItemPointOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([userId, createdAt], map: "old_item_point_entries_user_created_idx")
|
||||
@@index([donationId], map: "old_item_point_entries_donation_idx")
|
||||
@@map("old_item_point_entries")
|
||||
}
|
||||
|
||||
model OldItemInventoryImport {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
originalFilenameEncrypted String @map("original_filename_encrypted") @db.VarChar(512)
|
||||
rowCount Int @map("row_count") @db.UnsignedInt
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
creator User @relation("OldItemInventoryImportCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
items OldItemInventoryItem[]
|
||||
|
||||
@@unique([createdById, clientRequestId], map: "old_item_inventory_import_creator_request_key")
|
||||
@@map("old_item_inventory_imports")
|
||||
}
|
||||
|
||||
model OldItemInventoryItem {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
inventoryNo String @unique @map("inventory_no") @db.VarChar(32)
|
||||
sourceDonationId BigInt? @unique @map("source_donation_id") @db.UnsignedBigInt
|
||||
importId BigInt? @map("import_id") @db.UnsignedBigInt
|
||||
category OldItemCategory
|
||||
itemName String @map("item_name") @db.VarChar(160)
|
||||
quantity Int @db.UnsignedInt
|
||||
unit String @default("件") @db.VarChar(20)
|
||||
storageLocation String @map("storage_location") @db.VarChar(160)
|
||||
status OldItemInventoryStatus @default(IN_STOCK)
|
||||
targetNeedId BigInt? @map("target_need_id") @db.UnsignedBigInt
|
||||
beneficiaryId BigInt? @map("beneficiary_id") @db.UnsignedBigInt
|
||||
destinationRegion String? @map("destination_region") @db.VarChar(120)
|
||||
noteEncrypted String? @map("note_encrypted") @db.Text
|
||||
landingAt DateTime? @map("landing_at") @db.DateTime(3)
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
sourceDonation OldItemDonation? @relation(fields: [sourceDonationId], references: [id], onDelete: Restrict)
|
||||
import OldItemInventoryImport? @relation(fields: [importId], references: [id], onDelete: Restrict)
|
||||
targetNeed OldItemNeed? @relation(fields: [targetNeedId], references: [id], onDelete: Restrict)
|
||||
beneficiary BeneficiaryProfile? @relation(fields: [beneficiaryId], references: [id], onDelete: Restrict)
|
||||
creator User @relation("OldItemInventoryCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("OldItemInventoryUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
events OldItemInventoryEvent[]
|
||||
|
||||
@@index([status, category, createdAt], map: "old_item_inventory_status_category_created_idx")
|
||||
@@index([targetNeedId, status], map: "old_item_inventory_need_status_idx")
|
||||
@@index([beneficiaryId, status], map: "old_item_inventory_beneficiary_status_idx")
|
||||
@@map("old_item_inventory_items")
|
||||
}
|
||||
|
||||
model OldItemInventoryEvent {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
inventoryItemId BigInt @map("inventory_item_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
eventType OldItemInventoryEventType @map("event_type")
|
||||
fromStatus OldItemInventoryStatus? @map("from_status")
|
||||
toStatus OldItemInventoryStatus @map("to_status")
|
||||
locationText String? @map("location_text") @db.VarChar(160)
|
||||
noteEncrypted String? @map("note_encrypted") @db.Text
|
||||
eventAt DateTime @map("event_at") @db.DateTime(3)
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
inventoryItem OldItemInventoryItem @relation(fields: [inventoryItemId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("OldItemInventoryEventOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([inventoryItemId, eventAt], map: "old_item_inventory_events_item_event_idx")
|
||||
@@map("old_item_inventory_events")
|
||||
}
|
||||
|
||||
model OldItemDonationStatusHistory {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
donationId BigInt @map("donation_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
fromStatus OldItemDonationStatus? @map("from_status")
|
||||
toStatus OldItemDonationStatus @map("to_status")
|
||||
noteEncrypted String? @map("note_encrypted") @db.Text
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
donation OldItemDonation @relation(fields: [donationId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("OldItemDonationStatusOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([donationId, createdAt], map: "old_item_donation_history_donation_created_idx")
|
||||
@@map("old_item_donation_status_history")
|
||||
}
|
||||
|
||||
model OldItemDonationFile {
|
||||
donationId BigInt @map("donation_id") @db.UnsignedBigInt
|
||||
fileId BigInt @map("file_id") @db.UnsignedBigInt
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
attachedAt DateTime @default(now()) @map("attached_at") @db.DateTime(3)
|
||||
donation OldItemDonation @relation(fields: [donationId], references: [id], onDelete: Restrict)
|
||||
file File @relation(fields: [fileId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@id([donationId, fileId])
|
||||
@@index([fileId], map: "old_item_donation_files_file_idx")
|
||||
@@map("old_item_donation_files")
|
||||
}
|
||||
|
||||
model ServiceRecordFile {
|
||||
serviceRecordId BigInt @map("service_record_id") @db.UnsignedBigInt
|
||||
fileId BigInt @map("file_id") @db.UnsignedBigInt
|
||||
@@ -1158,24 +1554,24 @@ model ContentPostStatusHistory {
|
||||
}
|
||||
|
||||
model FinancialDisclosure {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
title String @db.VarChar(200)
|
||||
summary String? @db.VarChar(500)
|
||||
richText String @map("rich_text") @db.MediumText
|
||||
status FinancialDisclosureStatus @default(DRAFT)
|
||||
isPinned Boolean @default(false) @map("is_pinned")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
publishedAt DateTime? @map("published_at") @db.DateTime(3)
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("FinancialDisclosureCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("FinancialDisclosureUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
publicId String @unique @map("public_id") @db.Char(36)
|
||||
clientRequestId String @map("client_request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
title String @db.VarChar(200)
|
||||
summary String? @db.VarChar(500)
|
||||
richText String @map("rich_text") @db.MediumText
|
||||
status FinancialDisclosureStatus @default(DRAFT)
|
||||
isPinned Boolean @default(false) @map("is_pinned")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
revision Int @default(1) @db.UnsignedInt
|
||||
publishedAt DateTime? @map("published_at") @db.DateTime(3)
|
||||
createdById BigInt @map("created_by") @db.UnsignedBigInt
|
||||
updatedById BigInt @map("updated_by") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
creator User @relation("FinancialDisclosureCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
||||
updater User @relation("FinancialDisclosureUpdater", fields: [updatedById], references: [id], onDelete: Restrict)
|
||||
statusHistory FinancialDisclosureStatusHistory[]
|
||||
|
||||
@@unique([createdById, clientRequestId], map: "financial_disclosures_creator_request_key")
|
||||
@@ -1185,16 +1581,16 @@ model FinancialDisclosure {
|
||||
}
|
||||
|
||||
model FinancialDisclosureStatusHistory {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
financialDisclosureId BigInt @map("financial_disclosure_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
fromStatus FinancialDisclosureStatus? @map("from_status")
|
||||
toStatus FinancialDisclosureStatus @map("to_status")
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
financialDisclosure FinancialDisclosure @relation(fields: [financialDisclosureId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("FinancialDisclosureStatusOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
financialDisclosureId BigInt @map("financial_disclosure_id") @db.UnsignedBigInt
|
||||
requestId String @unique @map("request_id") @db.Char(36)
|
||||
requestFingerprint String @map("request_fingerprint") @db.Char(64)
|
||||
fromStatus FinancialDisclosureStatus? @map("from_status")
|
||||
toStatus FinancialDisclosureStatus @map("to_status")
|
||||
operatorUserId BigInt @map("operator_user_id") @db.UnsignedBigInt
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
financialDisclosure FinancialDisclosure @relation(fields: [financialDisclosureId], references: [id], onDelete: Restrict)
|
||||
operator User @relation("FinancialDisclosureStatusOperator", fields: [operatorUserId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([financialDisclosureId, createdAt], map: "financial_disclosure_history_document_idx")
|
||||
@@index([operatorUserId, createdAt], map: "financial_disclosure_history_operator_idx")
|
||||
|
||||
Reference in New Issue
Block a user