彻底优化数据库字段
This commit is contained in:
@@ -54,9 +54,6 @@ CREATE TABLE rental_listings (
|
||||
account_id BIGINT UNSIGNED NOT NULL,
|
||||
owner_id BIGINT UNSIGNED NOT NULL,
|
||||
price DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_hourly DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_daily DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
price_weekly DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
deposit_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
in_transaction TINYINT(1) NOT NULL DEFAULT 0,
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'draft',
|
||||
@@ -67,8 +64,7 @@ CREATE TABLE rental_listings (
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
KEY idx_rental_listings_account_id (account_id),
|
||||
KEY idx_rental_listings_owner_id (owner_id),
|
||||
KEY idx_rental_listings_filter (status, review_status, price),
|
||||
KEY idx_rental_listings_legacy_filter (status, review_status, price_hourly)
|
||||
KEY idx_rental_listings_filter (status, review_status, in_transaction, price)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE rental_orders (
|
||||
@@ -80,14 +76,12 @@ CREATE TABLE rental_orders (
|
||||
renter_id BIGINT UNSIGNED NOT NULL,
|
||||
rented_at DATETIME NULL,
|
||||
estimated_duration_hours INT NOT NULL DEFAULT 24,
|
||||
rent_start_at DATETIME NULL,
|
||||
rent_end_at DATETIME NULL,
|
||||
rent_hours INT NOT NULL,
|
||||
rent_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
owner_rent_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
deposit_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
platform_fee DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
account_snapshot JSON NULL,
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'pending_confirm',
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'pending_payment',
|
||||
handoff_status VARCHAR(32) NOT NULL DEFAULT 'none',
|
||||
settlement_status VARCHAR(32) NOT NULL DEFAULT 'unsettled',
|
||||
owner_settled_at DATETIME NULL,
|
||||
@@ -101,6 +95,33 @@ CREATE TABLE rental_orders (
|
||||
KEY idx_rental_orders_rented_at (status, rented_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE order_checkouts (
|
||||
id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
||||
order_id BIGINT UNSIGNED NOT NULL,
|
||||
initiated_by BIGINT UNSIGNED NOT NULL,
|
||||
status VARCHAR(32) NOT NULL DEFAULT 'submitted',
|
||||
rent_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
owner_rent_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
platform_fee DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
deposit_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
consumable_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
coin_consumed_m DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
other_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
deposit_deduct_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
renter_refund_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
owner_income_amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
||||
content TEXT NULL,
|
||||
evidence_urls JSON NULL,
|
||||
owner_adjustment_reason TEXT NULL,
|
||||
owner_adjusted_at DATETIME NULL,
|
||||
renter_confirmed_at DATETIME NULL,
|
||||
renter_rejected_at DATETIME NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
KEY idx_order_checkouts_order_id (order_id),
|
||||
KEY idx_order_checkouts_status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE handoff_records (
|
||||
id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
||||
order_id BIGINT UNSIGNED NOT NULL,
|
||||
@@ -141,6 +162,7 @@ CREATE TABLE wallet_ledger (
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_wallet_ledger_ledger_no (ledger_no),
|
||||
KEY idx_wallet_ledger_user_created (user_id, created_at),
|
||||
KEY idx_wallet_ledger_order_id (order_id),
|
||||
KEY idx_wallet_ledger_biz (biz_type, biz_no)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user