chore(migrations): add 069, 089, 090, 091 for v0.302
This commit is contained in:
parent
5fcd33618a
commit
6cd69f1e62
4 changed files with 65 additions and 0 deletions
31
veza-backend-api/migrations/069_groups_and_members.sql
Normal file
31
veza-backend-api/migrations/069_groups_and_members.sql
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-- Migration 069: Groups and group members (social groups)
|
||||
-- Required for v0.302 Lot S2 - groups may be used by GORM before this migration in some setups
|
||||
|
||||
CREATE TABLE IF NOT EXISTS groups (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
creator_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
avatar_url VARCHAR(500),
|
||||
is_public BOOLEAN NOT NULL DEFAULT true,
|
||||
member_count INT NOT NULL DEFAULT 1,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_groups_creator_id ON groups(creator_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_groups_is_public ON groups(is_public);
|
||||
CREATE INDEX IF NOT EXISTS idx_groups_deleted_at ON groups(deleted_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS group_members (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
group_id UUID NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
role VARCHAR(50) NOT NULL DEFAULT 'member',
|
||||
joined_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE(group_id, user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_group_members_group_id ON group_members(group_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_group_members_user_id ON group_members(user_id);
|
||||
16
veza-backend-api/migrations/089_group_join_requests.sql
Normal file
16
veza-backend-api/migrations/089_group_join_requests.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- Migration 089: Group join requests (private groups - request to join)
|
||||
-- v0.302 Lot S2.1
|
||||
|
||||
CREATE TABLE IF NOT EXISTS group_join_requests (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
group_id UUID NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected')),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE(group_id, user_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_group_join_requests_group_id ON group_join_requests(group_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_group_join_requests_user_id ON group_join_requests(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_group_join_requests_status ON group_join_requests(status);
|
||||
14
veza-backend-api/migrations/090_push_subscriptions.sql
Normal file
14
veza-backend-api/migrations/090_push_subscriptions.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- Migration 090: Web Push subscriptions (v0.302 Lot N1)
|
||||
-- Stores browser push subscription endpoints for Web Push API
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
endpoint TEXT NOT NULL,
|
||||
p256dh TEXT NOT NULL,
|
||||
auth TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
UNIQUE(user_id, endpoint)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_push_subscriptions_user_id ON push_subscriptions(user_id);
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
-- Migration 091: User presence invisible mode (v0.302 Lot P2.2)
|
||||
-- Adds invisible column to user_presence for hiding online status
|
||||
|
||||
ALTER TABLE user_presence ADD COLUMN IF NOT EXISTS invisible BOOLEAN NOT NULL DEFAULT false;
|
||||
Loading…
Reference in a new issue