func prepare()

in Sources/XCMetricsBackendLib/Common/Repositories/Postgress/Migrations/CreateBuildHost.swift [24:69]


    func prepare(on database: Database) -> EventLoopFuture<Void> {
        if let sql = database as? SQLDatabase {
            return sql.raw("""
            CREATE TABLE build_hosts (
                id text,
                day date NOT NULL,
                build_identifier text NOT NULL,
                host_os text NOT NULL,
                host_architecture text NOT NULL,
                host_model text NOT NULL,
                host_os_family text NOT NULL,
                host_os_version text NOT NULL,
                cpu_model text NOT NULL,
                cpu_count integer NOT NULL,
                cpu_speed_ghz double precision NOT NULL,
                memory_total_mb double precision NOT NULL,
                memory_free_mb double precision NOT NULL,
                swap_total_mb double precision NOT NULL,
                swap_free_mb double precision NOT NULL,
                uptime_seconds bigint NOT NULL,
                timezone text NOT NULL,
                is_virtual boolean NOT NULL,
                PRIMARY KEY (id, day)
            ) PARTITION BY LIST (day);
            """).run()
        }
        return database.schema("build_hosts")
            .field("id", .string, .identifier(auto: false))
            .field("build_identifier", .string, .required)
            .field("host_os", .string, .required)
            .field("host_architecture", .string, .required)
            .field("host_model", .string, .required)
            .field("host_os_family", .string, .required)
            .field("host_os_version", .string, .required)
            .field("cpu_model", .string, .required)
            .field("cpu_count", .int32, .required)
            .field("cpu_speed_ghz", .float, .required)
            .field("memory_total_mb", .double, .required)
            .field("memory_free_mb", .double, .required)
            .field("swap_total_mb", .double, .required)
            .field("swap_free_mb", .double, .required)
            .field("uptime_seconds", .int64, .required)
            .field("timezone", .string, .required)
            .field("is_virtual", .bool, .required)
            .create()
    }