-- PDS Entryway Account Management Schema
-- Minimal schema for account creation and authentication

-- Actor table - stores public identity information
CREATE TABLE actor (
    did VARCHAR PRIMARY KEY,
    handle VARCHAR,
    created_at VARCHAR NOT NULL
);

-- Case-insensitive unique index on handle
CREATE UNIQUE INDEX actor_handle_lower_idx ON actor (LOWER(handle));

-- Account table - stores private authentication data  
CREATE TABLE account (
    did VARCHAR PRIMARY KEY,
    email VARCHAR NOT NULL,
    password_scrypt VARCHAR NOT NULL,
    email_confirmed_at VARCHAR
);

-- Case-insensitive unique index on email
CREATE UNIQUE INDEX account_email_lower_idx ON account (LOWER(email));
