14 lines
665 B
SQL
14 lines
665 B
SQL
CREATE TABLE script_analyses (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL REFERENCES web_users(id) ON DELETE CASCADE,
|
|
name citext NOT NULL,
|
|
source_content text NOT NULL DEFAULT '',
|
|
result_content text NOT NULL DEFAULT '',
|
|
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at timestamptz
|
|
);
|
|
|
|
CREATE INDEX idx_script_analyses_user_updated ON script_analyses(user_id, updated_at DESC) WHERE deleted_at IS NULL;
|
|
CREATE TRIGGER script_analyses_updated_at BEFORE UPDATE ON script_analyses FOR EACH ROW EXECUTE FUNCTION set_updated_at();
|