ISSUE-33 #96

Merged
hitanshu merged 88 commits from kruti/CFTunnels:ISSUE-33 into test 2026-01-14 17:26:26 +00:00
Showing only changes of commit 6047471ff8 - Show all commits

View File

@ -1,29 +1,29 @@
--CREATE EXTENSION IF NOT EXISTS "pgcrypto";
--
--CREATE TABLE IF NOT EXISTS tunnels (
-- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- environment VARCHAR(10) NOT NULL,
-- cf_tunnel_id UUID UNIQUE NOT NULL
--);
--
--CREATE TABLE IF NOT EXISTS users (
-- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- name VARCHAR(50) NOT NULL
--);
--
--CREATE TABLE IF NOT EXISTS mappings (
-- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- tunnel_id UUID NOT NULL REFERENCES tunnels(id) ON DELETE CASCADE,
-- port INT NOT NULL,
-- subdomain VARCHAR(50) NOT NULL
---- UNIQUE (tunnel_id, port),
---- UNIQUE (tunnel_id, subdomain)
--);
--
--CREATE TABLE IF NOT EXISTS requests (
-- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- mapping_id UUID NOT NULL REFERENCES mappings(id) ON DELETE CASCADE,
-- created_by UUID NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
-- accepted_by UUID REFERENCES users(id) ON DELETE SET NULL,
-- status VARCHAR(20) NOT NULL CHECK (status IN ('PENDING', 'APPROVED', 'REJECTED'))
--);
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE TABLE IF NOT EXISTS tunnels (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
environment VARCHAR(10) NOT NULL,
cf_tunnel_id UUID UNIQUE NOT NULL
);
CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(50) NOT NULL
);
CREATE TABLE IF NOT EXISTS mappings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tunnel_id UUID NOT NULL REFERENCES tunnels(id) ON DELETE CASCADE,
port INT NOT NULL,
subdomain VARCHAR(50) NOT NULL
-- UNIQUE (tunnel_id, port),
-- UNIQUE (tunnel_id, subdomain)
);
CREATE TABLE IF NOT EXISTS requests (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
mapping_id UUID NOT NULL REFERENCES mappings(id) ON DELETE CASCADE,
created_by UUID NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
accepted_by UUID REFERENCES users(id) ON DELETE SET NULL,
status VARCHAR(20) NOT NULL CHECK (status IN ('PENDING', 'APPROVED', 'REJECTED'))
);