pg-schema-optimizer

1.0.1 • Public • Published

Postgres schema optimizer

Reorders columns in an SQL schema dump file so that they take up less space. It is a simpler and less robust alternative to pg_column_byte_packer.

The input schema should be well-formed, with each column occupying a single line.

Because it doesn't query a real database, columns with custom data types won't be recognized and will be moved to the end of the table.

CLI usage

npx pg-schema-optimizer -o optimized.sql unoptimized.sql

Library usage

import { optimize_schema } from 'pg-schema-optimizer'

console.log(
  optimize_schema(
    `create table "moomin" (
      "name" text not null,
      "age" int2 not null,
      "id" int not null primary key,
      "favourite_color" text
    );`,
  ),
)

/pg-schema-optimizer/

    Package Sidebar

    Install

    npm i pg-schema-optimizer

    Weekly Downloads

    4

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    9.65 kB

    Total Files

    6

    Last publish

    Collaborators

    • h3ruta