mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
26 lines
908 B
SQL
26 lines
908 B
SQL
-- +goose Up
|
|||
|
|
-- +goose StatementBegin
|
||
|
|
CREATE TABLE sessions (
|
||
|
|
id TEXT PRIMARY KEY,
|
||
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||
|
|
account_id TEXT NOT NULL,
|
||
|
|
user_agent TEXT,
|
||
|
|
ip_address TEXT,
|
||
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||
|
|
session_data JSONB,
|
||
|
|
FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
|
||
|
|
);
|
||
|
|
|
||
|
|
-- Indexes for performance
|
||
|
|
CREATE INDEX idx_sessions_account_id ON sessions(account_id);
|
||
|
|
CREATE INDEX idx_sessions_expires_at ON sessions(expires_at);
|
||
|
|
CREATE INDEX idx_sessions_is_active ON sessions(is_active) WHERE is_active = TRUE;
|
||
|
|
CREATE INDEX idx_sessions_created_at ON sessions(created_at);
|
||
|
|
-- +goose StatementEnd
|
||
|
|
|
||
|
|
-- +goose Down
|
||
|
|
-- +goose StatementBegin
|
||
|
|
DROP TABLE sessions;
|
||
|
|
-- +goose StatementEnd
|