CREATE TABLE resource_share_invitations (
 token_hash TEXT PRIMARY KEY,
 resource_kind TEXT NOT NULL,
 resource_slug TEXT NOT NULL,
 user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 permission TEXT NOT NULL CHECK(permission IN ('ro','rw')),
 created_by BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
 expires_at TEXT NOT NULL,
 accepted_at TEXT,
 created_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP::text),
 UNIQUE(resource_kind, resource_slug, user_id)
);
CREATE INDEX idx_resource_share_invitations_user ON resource_share_invitations(user_id);
