-- SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

CREATE TABLE IF NOT EXISTS cqrs_identity_role_query
(
    version           bigint CHECK (version >= 0) NOT NULL,

    created_time timestamp with time zone DEFAULT (CURRENT_TIMESTAMP) NOT NULL,

    name TEXT NOT NULL,

	role_id UUID NOT NULL UNIQUE,

	store_id UUID NOT NULL,

	deleted BOOLEAN NOT NULL DEFAULT FALSE,
	UNIQUE(name,store_id),

    PRIMARY KEY (role_id)
);
