Files
juwan-backend/desc/sql/wallet/wallets.sql
T
wwweww 19cc7a778c Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
2026-02-28 18:35:56 +08:00

19 lines
651 B
SQL

CREATE TABLE wallets
(
user_id BIGINT PRIMARY KEY,
balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
frozen_balance DECIMAL(12, 2) NOT NULL DEFAULT 0.00,
version INT NOT NULL DEFAULT 1, -- 必须使用乐观锁
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_balance_non_negative CHECK (balance >= 0),
CONSTRAINT chk_frozen_non_negative CHECK (frozen_balance >= 0)
);
CREATE INDEX idx_wallets_updated ON wallets (updated_at DESC);
CREATE TRIGGER trigger_wallets_updated_at
BEFORE UPDATE
ON wallets
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();