File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ -- database schema for sqlc code generation for archival PostgreSQL
2+
3+ CREATE TABLE sessions_archive (
4+ id UUID PRIMARY KEY ,
5+ username TEXT NOT NULL ,
6+ ip TEXT ,
7+ user_agent TEXT ,
8+ status TEXT CHECK (status IN (' active' , ' expired' )) NOT NULL ,
9+ created_at TIMESTAMP NOT NULL ,
10+ last_active_at TIMESTAMP NOT NULL ,
11+ expiry TIMESTAMP NOT NULL ,
12+ completed_count INTEGER DEFAULT 0 ,
13+ failed_count INTEGER DEFAULT 0 ,
14+ archived_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
15+ );
16+
17+ CREATE TABLE transactions_archive (
18+ id UUID PRIMARY KEY ,
19+ session_id UUID REFERENCES sessions_archive(id) ON DELETE CASCADE ,
20+ status TEXT CHECK (status IN (' success' , ' failure' )) NOT NULL ,
21+ output TEXT ,
22+ created_at TIMESTAMP NOT NULL
23+ );
24+
25+ -- indexes
26+ CREATE INDEX idx_transactions_session_id ON transactions_archive(session_id);
27+ CREATE INDEX idx_sessions_archive_time ON sessions_archive(archived_at DESC );
You can’t perform that action at this time.
0 commit comments