CREATE TABLE `email_senders` (
	`id` int AUTO_INCREMENT NOT NULL,
	`role` varchar(50) NOT NULL,
	`name` varchar(255) NOT NULL,
	`email` varchar(255) NOT NULL,
	`host` varchar(255),
	`port` int,
	`user` varchar(255),
	`password` text,
	`secure` boolean,
	`updated_at` timestamp ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `email_senders_id` PRIMARY KEY(`id`),
	CONSTRAINT `email_senders_role_unique` UNIQUE(`role`)
);
--> statement-breakpoint
CREATE TABLE `smtp_settings` (
	`id` int AUTO_INCREMENT NOT NULL,
	`host` varchar(255) NOT NULL,
	`port` int NOT NULL,
	`user` varchar(255),
	`password` text,
	`secure` boolean DEFAULT true,
	`from_name` varchar(255),
	`from_email` varchar(255),
	`updated_at` timestamp ON UPDATE CURRENT_TIMESTAMP,
	CONSTRAINT `smtp_settings_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
ALTER TABLE `buy_requests` ADD `license_sent_at` timestamp;--> statement-breakpoint
ALTER TABLE `licenses` ADD `request_id` int;--> statement-breakpoint
ALTER TABLE `payments` ADD `request_id` int;--> statement-breakpoint
ALTER TABLE `payments` ADD `license_id` int;--> statement-breakpoint
ALTER TABLE `payments` ADD `license_email_sent_at` timestamp;--> statement-breakpoint
ALTER TABLE `changelog_items` ADD CONSTRAINT `changelog_items_version_id_changelog_versions_id_fk` FOREIGN KEY (`version_id`) REFERENCES `changelog_versions`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE `payments` DROP COLUMN `license_key`;--> statement-breakpoint
ALTER TABLE `payments` DROP COLUMN `metadata`;