add scenarios methods

This commit is contained in:
2026-07-13 23:48:20 +07:00
parent 487b1aa436
commit db746f2123
17 changed files with 3620 additions and 118 deletions
@@ -5,7 +5,7 @@ CREATE TABLE
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(100) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
roles jsonb NOT NULL DEFAULT '[]'::jsonb,
roles JSONB NOT NULL DEFAULT '[]'::jsonb,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW ()
);
@@ -6,6 +6,7 @@ CREATE TABLE
expires_at TIMESTAMP NOT NULL,
jti VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW (),
CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);
@@ -0,0 +1,20 @@
-- +goose Up
CREATE TABLE
IF NOT EXISTS scenarios (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
image TEXT,
scenario JSONB NOT NULL DEFAULT '{}'::jsonb,
author_id INTEGER NOT NULL,
status VARCHAR(50) DEFAULT 'draft',
updated_at TIMESTAMP NOT NULL DEFAULT NOW (),
created_at TIMESTAMP NOT NULL DEFAULT NOW (),
published_at TIMESTAMP,
is_deleted BOOLEAN DEFAULT FALSE,
CONSTRAINT fk_scenarios_author FOREIGN KEY (author_id) REFERENCES users (id) ON DELETE RESTRICT
);
-- +goose Down
DROP TABLE IF EXISTS scenarios;