Skip to content

Commit b388d90

Browse files
author
0xMett
committed
feat(schema): add known_users, welcomed_users tables and welcome_delay_minutes column
New tables for user tracking and welcome-once-per-group. Add welcome_delay_minutes column to group_settings for configurable auto-delete delay. All statements are idempotent (IF NOT EXISTS).
1 parent 24ab2fa commit b388d90

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

schema.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,26 @@ CREATE TABLE IF NOT EXISTS global_bans (
6464
reason TEXT,
6565
created_at TIMESTAMPTZ DEFAULT NOW()
6666
);
67+
68+
CREATE TABLE IF NOT EXISTS known_users (
69+
user_id BIGINT PRIMARY KEY,
70+
username TEXT,
71+
first_name TEXT,
72+
last_name TEXT,
73+
updated_at TIMESTAMPTZ DEFAULT NOW()
74+
);
75+
76+
CREATE INDEX IF NOT EXISTS idx_known_users_username
77+
ON known_users (LOWER(username))
78+
WHERE username IS NOT NULL;
79+
80+
CREATE TABLE IF NOT EXISTS welcomed_users (
81+
user_id BIGINT NOT NULL,
82+
chat_id BIGINT NOT NULL,
83+
welcomed_at TIMESTAMPTZ DEFAULT NOW(),
84+
PRIMARY KEY (user_id, chat_id)
85+
);
86+
87+
-- Add welcome_delay_minutes column to group_settings (idempotent).
88+
ALTER TABLE group_settings
89+
ADD COLUMN IF NOT EXISTS welcome_delay_minutes INTEGER;

0 commit comments

Comments
 (0)