mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
43 lines
1.5 KiB
SQL
43 lines
1.5 KiB
SQL
-- fleets 0001: adopt_fleets
|
|
-- Generated by termix-plugin migrations. Review before committing.
|
|
|
|
CREATE TABLE IF NOT EXISTS `fleets` (
|
|
`id` int AUTO_INCREMENT PRIMARY KEY,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`name` text NOT NULL,
|
|
`description` text,
|
|
`color` text,
|
|
`icon` text,
|
|
`tag_rules` text,
|
|
`sync_id` varchar(255) UNIQUE,
|
|
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
|
);
|
|
RENAME TABLE `fleets` TO `p_fleets_fleets`;
|
|
CREATE TABLE IF NOT EXISTS `fleet_members` (
|
|
`id` int AUTO_INCREMENT PRIMARY KEY,
|
|
`fleet_id` int NOT NULL,
|
|
`host_id` int NOT NULL,
|
|
`added_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
FOREIGN KEY (`fleet_id`) REFERENCES `p_fleets_fleets` (`id`) ON DELETE CASCADE,
|
|
FOREIGN KEY (`host_id`) REFERENCES `ssh_data` (`id`) ON DELETE CASCADE
|
|
);
|
|
RENAME TABLE `fleet_members` TO `p_fleets_members`;
|
|
CREATE TABLE IF NOT EXISTS `fleet_inventory` (
|
|
`id` int AUTO_INCREMENT PRIMARY KEY,
|
|
`host_id` int NOT NULL,
|
|
`user_id` varchar(255) NOT NULL,
|
|
`os_pretty_name` text,
|
|
`kernel` text,
|
|
`architecture` text,
|
|
`hostname` text,
|
|
`uptime_seconds` int,
|
|
`ip` text,
|
|
`package_manager` text,
|
|
`collected_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
|
FOREIGN KEY (`host_id`) REFERENCES `ssh_data` (`id`) ON DELETE CASCADE,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
|
|
);
|
|
RENAME TABLE `fleet_inventory` TO `p_fleets_inventory`;
|