-- Migration: add access flags to existing bincio_activity database
-- Run once on the live DB: sqlite3 /var/bincio/data/instance.db < migrate.sql
-- Safe to run on a fresh DB (IF NOT EXISTS / OR IGNORE guards).

ALTER TABLE users ADD COLUMN wiki_access     INTEGER NOT NULL DEFAULT 1;
ALTER TABLE users ADD COLUMN activity_access INTEGER NOT NULL DEFAULT 0;
ALTER TABLE invites ADD COLUMN grants_activity INTEGER NOT NULL DEFAULT 0;

-- All existing users (registered via bincio_activity) get both access flags.
UPDATE users SET wiki_access = 1, activity_access = 1;

-- Set caps (adjust if needed before running).
INSERT OR REPLACE INTO settings VALUES ('max_wiki_users',     '100');
INSERT OR REPLACE INTO settings VALUES ('max_activity_users', '30');
