77trust / 100

Mysql To Pg Plan

by code.halowerk.com in Developer tools

x402 APIPassing, checked 3 h ago

Turn MySQL CREATE TABLE statements into a PostgreSQL schema and migration plan: documented type mapping, identities, enums, sets, zero dates, ON UPDATE triggers, indexes, foreign keys and load conversions.

POST
https://code.halowerk.com/v1/mysql-to-pg-plan
Price
$0.004
per call in USDC
Uptime
96.7%
last 30 days
Response time
124 ms
213 ms slowest 5%
Last check
Passed
3 h ago, next any minute now

Run a free test callHow to call it

Reliability

All checks passedSome failedAll failedNot checked

Status and outage history · Atom feed · Watch with other listings

How to call it

POST https://code.halowerk.com/v1/mysql-to-pg-plan

Each call costs $0.004 in USDC on Base, paid with the request over x402.

Run a free test callOne unpaid request, the way an agent sends it. You see the payment challenge it gets back. Nothing is charged.

Example request

From the listing.

POST https://code.halowerk.com/v1/mysql-to-pg-plan
content-type: application/json

{
  "mysql_ddl": "CREATE TABLE `users` (`id` int unsigned NOT NULL AUTO_INCREMENT, `email` varchar(191) NOT NULL, `is_active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
}

Parameters

ParameterTypeRequiredDescription
datetime_asstringNo One of: timestamptz, timestamp. Default: "timestamptz".
enum_asstringNo One of: enum_type, check. Default: "enum_type".
identitystringNo One of: identity, serial. Default: "identity".
mysql_ddlstringYes
tinyint1_as_booleanbooleanNo Default: true.
unsigned_checksbooleanNo Default: true.

Example response

The provider's example. We can't check it without paying.

Example response, 126 lines
{
  "limitations": [
    "Schema plan only: data, views, routines, triggers and partitions of MySQL are not converted.",
    "Collation and time-zone semantics differ between MySQL and PostgreSQL; test queries after migration."
  ],
  "result": {
    "postgres_ddl": "CREATE TABLE users (\n  id bigint GENERATED BY DEFAULT AS IDENTITY,\n  email varchar(191) NOT NULL,\n  is_active boolean DEFAULT true NOT NULL,\n  PRIMARY KEY (id)\n);\n",
    "steps": [
      {
        "sql": [
          "CREATE TABLE users (\n  id bigint GENERATED BY DEFAULT AS IDENTITY,\n  email varchar(191) NOT NULL,\n  is_active boolean DEFAULT true NOT NULL,\n  PRIMARY KEY (id)\n);"
        ],
        "step": 1,
        "title": "Create tables (primary keys only)"
      },
      {
        "always": true,
        "conversions": [
          {
            "column": "is_active",
            "conversion": "0 -> false, any other value -> true",
            "table": "users"
          }
        ],
        "note": "Load with pgloader or COPY; secondary indexes and foreign keys are added afterwards for speed.",
        "sql": [],
        "step": 2,
        "title": "Load data"
      },
      {
        "sql": [
          "SELECT setval(pg_get_serial_sequence('users', 'id'), COALESCE(MAX(id), 1), MAX(id) IS NOT NULL) FROM users;"
        ],
        "step": 3,
        "title": "Reset identity sequences"
      },
      {
        "note": "Compare the row counts with SELECT COUNT(*) on MySQL.",
        "sql": [
          "ANALYZE;",
          "SELECT count(*) FROM users;"
        ],
        "step": 4,
        "title": "Verify"
      }
    ],
    "summary": {
      "columns": 3,
      "enum_types": 0,
      "foreign_keys": 0,
      "indexes": 0,
      "skipped_statements": 0,
      "tables": 1,
      "triggers": 0
    },
    "tables": [
      {
        "columns": [
          {
            "checks": [],
            "column": "id",
            "default": null,
            "mysql_type": "int unsigned",
            "notes": [
              "INT UNSIGNED reaches 4294967295, above PostgreSQL integer."
            ],
            "nullable": false,
            "postgres_type": "bigint GENERATED BY DEFAULT AS IDENTITY",
            "rule_source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
          },
          {
            "checks": [],
            "column": "email",
            "default": null,
            "mysql_type": "varchar(191)",
            "notes": [],
            "nullable": false,
            "postgres_type": "varchar(191)",
            "rule_source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
          },
          {
            "checks": [],
            "column": "is_active",
            "default": "true",
            "mysql_type": "tinyint(1)",
            "notes": [
              "tinyint(1) is MySQL's BOOLEAN (pgloader rule \"tinyint when (= 1 precision) to boolean\"); values other than 0 and 1 become true."
            ],
            "nullable": false,
            "postgres_type": "boolean",
            "rule_source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
          }
        ],
        "engine": "InnoDB",
        "indexes": [],
        "mysql_table": "users",
        "primary_key": [
          "id"
        ],
        "table": "users"
      }
    ],
    "type_mappings": [
      {
        "mysql": "int unsigned auto_increment",
        "postgres": "bigint GENERATED BY DEFAULT AS IDENTITY",
        "source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
      },
      {
        "mysql": "varchar(191)",
        "postgres": "varchar(191)",
        "source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
      },
      {
        "mysql": "tinyint(1)",
        "postgres": "boolean",
        "source": "https://github.com/dimitri/pgloader/blob/231ab86778ca5ffd7de40878714760c8b4860cdf/docs/ref/mysql.rst#default-mysql-casting-rules"
      }
    ],
    "warnings": [
      "users: MySQL compares strings case-insensitively (default collation); PostgreSQL does not. Use citext, lower() indexes or a nondeterministic ICU collation where needed."
    ]
  },
  "service": "mysql-to-pg-plan",
  "status": "success"
}

Call it from code

The curl command shows the payment challenge. The JavaScript and Python versions pay and call, and never pay more than $0.004.

curl: see the payment challenge
# bash or zsh: see the payment challenge. Nothing is charged.
curl -sS -g -i -X POST 'https://code.halowerk.com/v1/mysql-to-pg-plan' \
  -H 'content-type: application/json' \
  --data-raw '{"mysql_ddl":"CREATE TABLE `users` (`id` int unsigned NOT NULL AUTO_INCREMENT, `email` varchar(191) NOT NULL, `is_active` tinyint(1) NOT NULL DEFAULT '\''1'\'', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"}'

# x402 v2 sends the challenge base64-encoded in the PAYMENT-REQUIRED header (v1 sends it in the body).
# To read the header:
curl -sS -g -o /dev/null -D - -X POST 'https://code.halowerk.com/v1/mysql-to-pg-plan' \
  -H 'content-type: application/json' \
  --data-raw '{"mysql_ddl":"CREATE TABLE `users` (`id` int unsigned NOT NULL AUTO_INCREMENT, `email` varchar(191) NOT NULL, `is_active` tinyint(1) NOT NULL DEFAULT '\''1'\'', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"}' \
  | grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 --decode
JavaScript: pay and call
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

// Pays at most $0.004 per call.
const client = new x402Client().setSpendControls({ maxAmountPerPayment: "$0.004" });
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? ToolVet checks it first for $0.005. Pay for that from a separate
// client: this one is capped at $0.004 per payment. GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fcode.halowerk.com%2Fv1%2Fmysql-to-pg-plan&method=POST
const res = await pay("https://code.halowerk.com/v1/mysql-to-pg-plan", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    "mysql_ddl": "CREATE TABLE `users` (`id` int unsigned NOT NULL AUTO_INCREMENT, `email` varchar(191) NOT NULL, `is_active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
  }),
});
console.log(res.status, await res.text());
Python: pay and call
# pip install "x402[requests,evm]"
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client

# Pays at most $0.004 per call.
client = x402ClientSync().set_spend_controls({"max_amount_per_payment": "$0.004"})
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))

with x402_requests(client) as session:
    res = session.post(
        "https://code.halowerk.com/v1/mysql-to-pg-plan",
        json={
            "mysql_ddl": "CREATE TABLE `users` (`id` int unsigned NOT NULL AUTO_INCREMENT, `email` varchar(191) NOT NULL, `is_active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;",
        },
    )
    print(res.status_code, res.text)

Security scan

No findings

We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
3 h agoPassed402146 ms$0.004
14 h agoPassed402253 ms$0.004
24 h agoPassed402126 ms$0.004
34 h agoPassed402130 ms$0.004
44 h agoPassed40238 ms$0.004
Show 10 older checks
2 days agoPassed40242 ms$0.004
3 days agoPassed402121 ms$0.004
5 days agoTimed out---
6 days agoPassed402122 ms$0.004
7 days agoPassed40238 ms$0.004
7 days agoPassed402134 ms$0.004
7 days agoPassed402121 ms$0.004
8 days agoPassed402125 ms$0.004
8 days agoPassed402132 ms$0.004
8 days agoPassed402130 ms$0.004