BEGIN;
CREATE OR REPLACE FUNCTION openreplay_version()
    RETURNS text AS
$$
SELECT 'v1.9.5-ee'
$$ LANGUAGE sql IMMUTABLE;

CREATE TABLE IF NOT EXISTS assist_records
(
    record_id  integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
    project_id integer                     NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
    user_id    integer                     NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
    session_id bigint                      NOT NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
    created_at bigint                      NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
    deleted_at timestamp without time zone NULL     DEFAULT NULL,
    name       text                        NOT NULL,
    file_key   text                        NOT NULL,
    duration   integer                     NOT NULL
);

COMMIT;