feat: Implement dispute flow with database schema and API endpoints
This commit is contained in:
parent
431ced05b5
commit
2268ef56d8
9 changed files with 454 additions and 0 deletions
28
backend/sql/dispute-schema.sql
Normal file
28
backend/sql/dispute-schema.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
CREATE TABLE IF NOT EXISTS disputes (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
deal_id BIGINT NOT NULL,
|
||||
opened_by_user_id BIGINT NOT NULL,
|
||||
status ENUM('open','evidence','mediation','resolved','cancelled') NOT NULL DEFAULT 'open',
|
||||
reason_code VARCHAR(64) NOT NULL,
|
||||
summary TEXT NOT NULL,
|
||||
requested_outcome VARCHAR(64) NOT NULL,
|
||||
final_decision VARCHAR(64) NULL,
|
||||
final_reason TEXT NULL,
|
||||
decided_by_user_id BIGINT NULL,
|
||||
decided_at TIMESTAMP NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (deal_id) REFERENCES deals(id),
|
||||
FOREIGN KEY (opened_by_user_id) REFERENCES users(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dispute_events (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
dispute_id BIGINT NOT NULL,
|
||||
event_type VARCHAR(64) NOT NULL,
|
||||
actor_user_id BIGINT NOT NULL,
|
||||
payload_json JSON NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (dispute_id) REFERENCES disputes(id),
|
||||
FOREIGN KEY (actor_user_id) REFERENCES users(id)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue