CREATE TABLE `rss_feeds` (
	`id` int AUTO_INCREMENT NOT NULL,
	`url` text NOT NULL,
	`name` varchar(255) NOT NULL,
	`feedType` enum('veille','aap') NOT NULL,
	`defaultTypeVeille` enum('reglementaire','concurrentielle','technologique','generale'),
	`defaultCategorieAap` enum('Handicap','PA','Enfance','Précarité','Sanitaire','Autre'),
	`autoRules` json,
	`isActive` boolean NOT NULL DEFAULT true,
	`lastFetchedAt` timestamp,
	`lastFetchStatus` enum('ok','error','pending') DEFAULT 'pending',
	`lastFetchError` text,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `rss_feeds_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `rss_settings` (
	`id` int AUTO_INCREMENT NOT NULL,
	`fetchIntervalMinutes` int NOT NULL DEFAULT 360,
	`scheduledTime` varchar(5) DEFAULT '06:00',
	`fetchMode` enum('interval','scheduled') NOT NULL DEFAULT 'scheduled',
	`autoFetchEnabled` boolean NOT NULL DEFAULT true,
	`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `rss_settings_id` PRIMARY KEY(`id`)
);
