Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@wmfs/pg-diff-sync
Advanced tools
Takes two objects that describe the structure of a database and produces the PostgreSQL statements required to get from one to the other.
Takes two objects that describe the structure of a database and produces the PostgreSQL statements required to get from one to the other.
$ npm install pg-diff-sync --save
const pgDiffSync = require('pg-diff-sync')
const currentDbStructure = {...}
const expectedDbStructure = {...}
const statements = pgDiffSync(
currentDbStructure,
expectedDbStructure
)
// Returns an array of DDL statements to apply on the PostgreSQL database
Arg | Type | Notes |
---|---|---|
baseDbStructure | object | An object representing the original starting position of a database - most likely the output conjured from the pg-info package |
targetDbStructure | object | And an object representing how the database needs to be - in the same form as baseDbStructure (again see the pg-info package for more details) |
The output from pg-diff-sync is a simple array of strings.
baseDbStructure
object.Example output
[
"CREATE SCHEMA pg_diff_sync_test;",
"COMMENT ON SCHEMA pg_diff_sync_test IS 'Schema auto-generated by Relationize.js!';",
"CREATE TABLE pg_diff_sync_test.people();",
"COMMENT ON TABLE pg_diff_sync_test.people IS 'Just a simple list of people!';",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN employee_no text NOT NULL;",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN first_name text NOT NULL;",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN last_name text NOT NULL;",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN age integer;",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN _created timestamp with time zone NOT NULL DEFAULT now();",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN _created_by text;",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN _modified timestamp with time zone NOT NULL DEFAULT now();",
"ALTER TABLE pg_diff_sync_test.people ADD COLUMN _modified_by text;",
"COMMENT ON COLUMN pg_diff_sync_test.people.first_name IS 'Person''s first name';",
"COMMENT ON COLUMN pg_diff_sync_test.people.age IS 'Age in years';",
"COMMENT ON COLUMN pg_diff_sync_test.people._created IS 'Timestamp for when this record was created';",
"COMMENT ON COLUMN pg_diff_sync_test.people._created_by IS 'UserID that created this record (if known)';",
"COMMENT ON COLUMN pg_diff_sync_test.people._modified IS 'Timestamp for when this record was last updated';",
"COMMENT ON COLUMN pg_diff_sync_test.people._modified_by IS 'UserID that last modified this record (if known)';",
"ALTER TABLE pg_diff_sync_test.people ADD PRIMARY KEY (employee_no);",
"CREATE UNIQUE INDEX people_first_name_last_name_idx ON pg_diff_sync_test.people (first_name,last_name);"
]
$ npm test
FAQs
Takes two objects that describe the structure of a database and produces the PostgreSQL statements required to get from one to the other.
The npm package @wmfs/pg-diff-sync receives a total of 714 weekly downloads. As such, @wmfs/pg-diff-sync popularity was classified as not popular.
We found that @wmfs/pg-diff-sync demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.