CREATE TABLE `content_playlist` (
	`content_item_id` integer NOT NULL,
	`playlist_id` integer NOT NULL,
	PRIMARY KEY(`content_item_id`, `playlist_id`),
	FOREIGN KEY (`content_item_id`) REFERENCES `content_items`(`id`) ON UPDATE no action ON DELETE cascade,
	FOREIGN KEY (`playlist_id`) REFERENCES `playlists`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `playlists` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`creator_id` integer NOT NULL,
	`platform_playlist_id` text NOT NULL,
	`title` text NOT NULL,
	`position` integer DEFAULT 0 NOT NULL,
	`created_at` text DEFAULT (datetime('now')) NOT NULL,
	`updated_at` text DEFAULT (datetime('now')) NOT NULL,
	FOREIGN KEY (`creator_id`) REFERENCES `creators`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
ALTER TABLE `content_items` ADD `published_at` text;--> statement-breakpoint
ALTER TABLE `content_items` ADD `downloaded_at` text;--> statement-breakpoint
ALTER TABLE `content_items` ADD `monitored` integer DEFAULT true NOT NULL;--> statement-breakpoint
ALTER TABLE `creators` ADD `monitoring_mode` text DEFAULT 'all' NOT NULL;