Files
smart-search-back/migrations/00003_create_invite_codes.sql
vallyenfail 5487618019
All checks were successful
Deploy Smart Search Backend / deploy (push) Successful in 1m41s
add service
2026-01-17 23:40:43 +03:00

18 lines
553 B
SQL

-- +goose Up
CREATE TABLE IF NOT EXISTS invite_codes (
id SERIAL PRIMARY KEY,
user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
code BIGINT NOT NULL UNIQUE,
can_be_used_count INT DEFAULT 10,
used_count INT DEFAULT 0,
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT now(),
expires_at TIMESTAMP NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_invite_codes_code ON invite_codes(code);
CREATE INDEX IF NOT EXISTS idx_invite_codes_user_id ON invite_codes(user_id);
-- +goose Down
DROP TABLE invite_codes;