-- AtlasOS - Calypso -- Add ZFS Pools Table -- Version: 4.0 -- Note: This migration adds the zfs_pools table that was added to migration 002 -- but may not have been applied if migration 002 was run before the table was added -- ZFS pools table CREATE TABLE IF NOT EXISTS zfs_pools ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name VARCHAR(255) NOT NULL UNIQUE, description TEXT, raid_level VARCHAR(50) NOT NULL, -- stripe, mirror, raidz, raidz2, raidz3 disks TEXT[] NOT NULL, -- array of device paths size_bytes BIGINT NOT NULL, used_bytes BIGINT NOT NULL DEFAULT 0, compression VARCHAR(50) NOT NULL DEFAULT 'lz4', -- off, lz4, zstd, gzip deduplication BOOLEAN NOT NULL DEFAULT false, auto_expand BOOLEAN NOT NULL DEFAULT false, scrub_interval INTEGER NOT NULL DEFAULT 30, -- days is_active BOOLEAN NOT NULL DEFAULT true, health_status VARCHAR(50) NOT NULL DEFAULT 'online', -- online, degraded, faulted, offline created_at TIMESTAMP NOT NULL DEFAULT NOW(), updated_at TIMESTAMP NOT NULL DEFAULT NOW(), created_by UUID REFERENCES users(id) ); -- Create index on name for faster lookups CREATE INDEX IF NOT EXISTS idx_zfs_pools_name ON zfs_pools(name); CREATE INDEX IF NOT EXISTS idx_zfs_pools_created_by ON zfs_pools(created_by); CREATE INDEX IF NOT EXISTS idx_zfs_pools_health_status ON zfs_pools(health_status);