Skip to content
BI Data

JSON Schema → DB Diff: PostgreSQL Migrations

About this tool

Compare two database structures in the JSON format shown below and generate PostgreSQL migration SQL. Review the generated statements and test them on a disposable database before use.

How to use it

Paste the old and new database structures as JSON. The tool compares them and generates PostgreSQL ALTER statements. DROP operations can delete data; inspect the script before running it.

Supported operations

  • CREATE TABLE — create tables
  • DROP TABLE — remove tables
  • ADD COLUMN — add columns
  • DROP COLUMN — remove columns
  • ALTER COLUMN — change data types
  • CREATE INDEX — create indexes
  • DROP INDEX — remove indexes

JSON input format

{
  "tables": {
    "users": {
      "columns": {
        "id": {
          "type": "SERIAL",
          "primary_key": true
        },
        "name": {
          "type": "VARCHAR(255)",
          "nullable": false
        }
      },
      "indexes": ["name"]
    }
  }
}
JSON describing the current database structure
JSON describing the target database structure

Comparison result

Tables: --
Columns: --
Indexes: --

PostgreSQL migration SQL:


    

Operations:

PostgreSQL data types

Numeric

  • SERIAL, BIGSERIAL
  • INTEGER, BIGINT
  • DECIMAL(p,s), NUMERIC(p,s)
  • REAL, DOUBLE PRECISION

Text

  • VARCHAR(n), CHAR(n)
  • TEXT
  • UUID

Date and time

  • DATE
  • TIME, TIMESTAMP
  • TIMESTAMPTZ

Other

  • BOOLEAN
  • JSON, JSONB
  • BYTEA

More tools

Free tools for analysts and developers