2024-05-17 23:28:38 +05:30
|
|
|
-- SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
--
|
|
|
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2024-07-14 18:24:24 +05:30
|
|
|
CREATE TABLE IF NOT EXISTS events
|
2024-05-17 23:28:38 +05:30
|
|
|
(
|
|
|
|
aggregate_type text NOT NULL,
|
|
|
|
aggregate_id text NOT NULL,
|
|
|
|
sequence bigint CHECK (sequence >= 0) NOT NULL,
|
|
|
|
event_type text NOT NULL,
|
|
|
|
event_version text NOT NULL,
|
|
|
|
payload json NOT NULL,
|
|
|
|
metadata json NOT NULL,
|
|
|
|
timestamp timestamp with time zone DEFAULT (CURRENT_TIMESTAMP),
|
|
|
|
PRIMARY KEY (aggregate_type, aggregate_id, sequence)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS user_query
|
|
|
|
(
|
|
|
|
view_id text NOT NULL,
|
|
|
|
version bigint CHECK (version >= 0) NOT NULL,
|
|
|
|
|
|
|
|
username TEXT NOT NULL UNIQUE,
|
|
|
|
email TEXT NOT NULL UNIQUE,
|
|
|
|
hashed_password TEXT NOT NULL,
|
|
|
|
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
is_verified BOOLEAN NOT NULL DEFAULT FALSE,
|
2024-05-19 00:39:01 +05:30
|
|
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
2024-05-17 23:28:38 +05:30
|
|
|
|
|
|
|
PRIMARY KEY (view_id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS user_username_index ON user_query (username);
|