fix: settle anonymous single-file reservations
This commit is contained in:
20
migrations/022_anonymous_single_reservations.sql
Normal file
20
migrations/022_anonymous_single_reservations.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE anonymous_single_reservations (
|
||||
task_id UUID PRIMARY KEY,
|
||||
session_id VARCHAR(100) NOT NULL,
|
||||
client_ip INET NOT NULL,
|
||||
quota_date DATE NOT NULL,
|
||||
units INTEGER NOT NULL,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'pending',
|
||||
refund_after TIMESTAMPTZ NOT NULL DEFAULT (NOW() + INTERVAL '15 minutes'),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
settled_at TIMESTAMPTZ,
|
||||
CONSTRAINT anonymous_single_reservations_units_check
|
||||
CHECK (units > 0),
|
||||
CONSTRAINT anonymous_single_reservations_status_check
|
||||
CHECK (status IN ('pending', 'charged', 'refund_pending', 'refunded'))
|
||||
);
|
||||
|
||||
CREATE INDEX anonymous_single_reservations_unsettled
|
||||
ON anonymous_single_reservations(refund_after, created_at)
|
||||
WHERE status IN ('pending', 'refund_pending');
|
||||
Reference in New Issue
Block a user