
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
postgres-forward-migration
Advanced tools
A simple forwards only migration solution for [postgres.js](https://github.com/porsager/postgres)
postgres-shift
A simple forwards only migration solution for postgres.js.
postgres-shift
shift()
postgres-shift
exports a single function which is used to start migrations.
It expects a postgres.js sql database object to run migrations with.
Example
migrations
directory with following structure.
└── migrations
├── 00001_initial
│ └── index.sql
├── 00002_update
│ └── index.js
└── 00003_delete
└── index.sql
Note that migration folder name expects 5 digits. This is very important detail.
create table test (
a text,
b int
)
export default async function(sql) {
await sql`
alter table test add column c timestamp with time zone
`
await sql`
insert into test (a, b, c) values ('hello', 9, ${ new Date() })
`
}
migrate.js
script:import shift from 'postgres-shift';
import postgres from 'postgres';
import { fileURLToPath } from 'url';
const {
DB_HOST,
DB_PORT,
DB_NAME,
ADMIN_DB_USER,
ADMIN_DB_PASSWORD,
} = process.env;
export const sql = postgres({
host: DB_HOST,
port: Number(DB_PORT),
database: DB_NAME,
user: ADMIN_DB_USER,
pass: ADMIN_DB_PASSWORD,
idle_timeout: 1,
});
shift({
sql,
path: fileURLToPath(new URL('migrations', import.meta.url)),
before: ({ migration_id, name }) => {
console.log('Migrating', migration_id, name);
},
})
.then(() => console.log('All good'))
.catch((err) => {
console.error('Failed', err);
process.exit(1);
});
node ./migrate.js
FAQs
A simple forwards only migration solution for [postgres.js](https://github.com/porsager/postgres)
The npm package postgres-forward-migration receives a total of 1 weekly downloads. As such, postgres-forward-migration popularity was classified as not popular.
We found that postgres-forward-migration 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.