-- A real "user" (claimant/creator) entity with its own id, so a real
-- reference to a specific person can exist instead of only ever a
-- free-text name -- two people with the same display name are still
-- distinguishable by id, and a person can be referenced without needing a
-- name or email at all (both optional; a name alone, an email alone, or
-- neither is fine -- the id is what actually identifies the row).
--
-- Purely additive for now: claim_links.user_id is a nullable FK alongside
-- its existing creator_tag (free text), not a replacement for it -- no
-- existing claim_links row is touched, and nothing yet requires picking a
-- real user instead of typing a tag. Wiring the admin forms to actually
-- create/pick users.id values, and backfilling existing creator_tag
-- values into rows here, is a separate follow-up.

CREATE TABLE IF NOT EXISTS users (
    id         BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name       VARCHAR(190) NULL,
    email      VARCHAR(190) NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE claim_links ADD COLUMN user_id BIGINT UNSIGNED NULL AFTER creator_tag;
ALTER TABLE claim_links ADD CONSTRAINT fk_link_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
