CREATE TABLE `cashOfferLeads` (
	`id` int AUTO_INCREMENT NOT NULL,
	`propertyAddress` varchar(512) NOT NULL,
	`name` varchar(160) NOT NULL,
	`phone` varchar(48) NOT NULL,
	`email` varchar(320),
	`timeline` varchar(120),
	`leadSource` varchar(120) NOT NULL,
	`consent` boolean NOT NULL DEFAULT false,
	`webhookStatus` enum('not_configured','pending','delivered','failed') NOT NULL DEFAULT 'not_configured',
	`webhookError` text,
	`webhookAttemptedAt` timestamp,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `cashOfferLeads_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `users` (
	`id` int AUTO_INCREMENT NOT NULL,
	`openId` varchar(64) NOT NULL,
	`name` text,
	`email` varchar(320),
	`loginMethod` varchar(64),
	`role` enum('user','admin') NOT NULL DEFAULT 'user',
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	`lastSignedIn` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `users_id` PRIMARY KEY(`id`),
	CONSTRAINT `users_openId_unique` UNIQUE(`openId`)
);
