CREATE TABLE `auth_sessions` (
	`id` int unsigned AUTO_INCREMENT NOT NULL,
	`actor_type` enum('customer','staff') NOT NULL,
	`actor_id` int unsigned NOT NULL,
	`refresh_token_hash` varchar(255) NOT NULL,
	`user_agent` varchar(512),
	`ip_address` varchar(80),
	`expires_at` timestamp NOT NULL,
	`revoked_at` timestamp,
	`last_used_at` timestamp,
	`created_at` timestamp NOT NULL DEFAULT (now()),
	`updated_at` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `auth_sessions_id` PRIMARY KEY(`id`),
	CONSTRAINT `auth_sessions_refresh_token_hash_unique` UNIQUE(`refresh_token_hash`)
);
--> statement-breakpoint
CREATE INDEX `auth_sessions_actor_idx` ON `auth_sessions` (`actor_type`,`actor_id`);--> statement-breakpoint
CREATE INDEX `auth_sessions_expires_idx` ON `auth_sessions` (`expires_at`);