CREATE TABLE `affiliate_clicks` (
	`id` int AUTO_INCREMENT NOT NULL,
	`staffId` int NOT NULL,
	`productId` int NOT NULL,
	`affiliateLinkId` int,
	`visitorIp` varchar(64),
	`userAgent` text,
	`referer` varchar(500),
	`source` varchar(100),
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `affiliate_clicks_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `affiliate_links` (
	`id` int AUTO_INCREMENT NOT NULL,
	`staffId` int NOT NULL,
	`productId` int NOT NULL,
	`slug` varchar(100) NOT NULL,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `affiliate_links_id` PRIMARY KEY(`id`),
	CONSTRAINT `affiliate_links_slug_unique` UNIQUE(`slug`)
);
--> statement-breakpoint
CREATE TABLE `system_config` (
	`key` varchar(100) NOT NULL,
	`value` text,
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `system_config_key` PRIMARY KEY(`key`)
);
