|
| 1 | +-- Rule-engine schema + seed for the (ORDER_FLOW, ACME) use case. |
| 2 | +-- The app reads these rows over the MySQL wire; Keploy captures that traffic |
| 3 | +-- as mocks and serves it back on replay. |
| 4 | +CREATE DATABASE IF NOT EXISTS ruledb; |
| 5 | +USE ruledb; |
| 6 | + |
| 7 | +CREATE TABLE IF NOT EXISTS rules ( |
| 8 | + rule_id BIGINT PRIMARY KEY, |
| 9 | + use_case VARCHAR(64) NOT NULL, |
| 10 | + tenant VARCHAR(64) NOT NULL, |
| 11 | + constraint_expr TEXT NOT NULL, |
| 12 | + rule_type VARCHAR(16) NOT NULL, |
| 13 | + INDEX idx_uc_tenant (use_case, tenant) |
| 14 | +); |
| 15 | + |
| 16 | +CREATE TABLE IF NOT EXISTS rule_actions ( |
| 17 | + id BIGINT AUTO_INCREMENT PRIMARY KEY, |
| 18 | + rule_id BIGINT NOT NULL, |
| 19 | + basic_action VARCHAR(255) NOT NULL, |
| 20 | + action_details TEXT NOT NULL, |
| 21 | + seq INT NOT NULL, |
| 22 | + INDEX idx_rule (rule_id) |
| 23 | +); |
| 24 | + |
| 25 | +INSERT INTO rules (rule_id, use_case, tenant, constraint_expr, rule_type) VALUES |
| 26 | + (14,'ORDER_FLOW','ACME','status == "COMPLETED" && type.equals("CHECKOUT")','POST'), |
| 27 | + (15,'ORDER_FLOW','ACME','status == "COMPLETED" && type.equals("PAYMENT")','POST'), |
| 28 | + (16,'ORDER_FLOW','ACME','status == "COMPLETED" && type.equals("SHIPMENT")','POST'), |
| 29 | + (17,'ORDER_FLOW','ACME','status == "IN_PROGRESS" && type.equals("REFUND")','POST'), |
| 30 | + (18,'ORDER_FLOW','ACME','status == "COMPLETED" && type.equals("FULFILLMENT")','PRE'); |
| 31 | + |
| 32 | +INSERT INTO rule_actions (rule_id, basic_action, action_details, seq) VALUES |
| 33 | + (14,'com.example.rules.handlers.ForceSyncHandler','{}',1), |
| 34 | + (15,'com.example.rules.handlers.PaymentTaskHandler','{}',1), |
| 35 | + (15,'com.example.rules.handlers.NotifyHandler','{"optional":"true","channel":"email"}',2), |
| 36 | + (16,'com.example.rules.handlers.ValidateHandler','{"optional":"true"}',1), |
| 37 | + (16,'com.example.rules.handlers.ShipmentHandler','{}',2), |
| 38 | + (17,'com.example.rules.handlers.RefundHandler','{}',1), |
| 39 | + (18,'com.example.rules.handlers.ImageSyncHandler','{"optional":"true"}',1); |
0 commit comments