Files
leonwww/dns/migrations/004_add_domain_invite_codes.sql
2025-08-12 21:31:09 +03:00

17 lines
776 B
SQL

-- Add domain_invite_codes field to users table
ALTER TABLE users ADD COLUMN domain_invite_codes INTEGER DEFAULT 3;
-- Create domain invite codes table for domain-specific invites
CREATE TABLE IF NOT EXISTS domain_invite_codes (
id SERIAL PRIMARY KEY,
code VARCHAR(32) UNIQUE NOT NULL,
created_by INTEGER REFERENCES users(id),
used_by INTEGER REFERENCES users(id),
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
used_at TIMESTAMPTZ
);
-- Create indexes for faster lookups
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_code ON domain_invite_codes(code);
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_created_by ON domain_invite_codes(created_by);
CREATE INDEX IF NOT EXISTS idx_domain_invite_codes_used_by ON domain_invite_codes(used_by);