-- Ported from the SQLite migration of the same number. -- Which directory keeps an account, and its id there: an Active Directory -- objectGUID, so a person whose mail changes there is still the same account -- here. suspended_by_sync is an account the directory sync suspended, -- because it was disabled or gone there; one an administrator suspended -- here is not, and is never reinstated by the sync. CREATE TABLE user_directory ( user_id TEXT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE, directory TEXT NOT NULL, external_id TEXT NOT NULL, suspended_by_sync INTEGER NOT NULL DEFAULT 0, synced_at BIGINT NOT NULL DEFAULT 0, UNIQUE (directory, external_id) );