prisma-tunneled-deploy
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

prisma-tunneled-deploy

Apply Prisma Databse migrations through an SSH tunnel

Installation

pnpm add -D prisma-tunneled-deploy

Usage

Deploy migrations through a script

  1. Create a new file where you source all the required inputs.

    // ./scripts/deploy.mjs
    import { deployMigrations } from 'prisma-tunneled-deploy';
    import { readFileSync } from 'fs';
    
    const dbCredentials = {
      host: 'localhost',
      port: 5432,
      username: 'postgres',
      password: 'postgres',
    };
    
    await deployMigrations(
      {
        ...dbCredentials,
        url: `postgresql://${dbCredentials.username}:${dbCredentials.password}@${dbCredentials.host}:${dbCredentials.port}`,
      },
      {
        // details of the bastion host used for SSH tunneling
        host: '192.168.100.100',
        privateKey: readFileSync('/path/to/my/key').toString('utf-8'),
        username: 'ubuntu',
      }
    );
  2. Set up a script in your package.json file that will execute it:

    {
      "scripts": {
        "migrate:deploy": "./scripts/deploy.mjs"
      }
    }
  3. Make sure the file is executable, and run the script:

    pnpm migrate:deploy

Package Sidebar

Install

npm i prisma-tunneled-deploy

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

8.51 kB

Total Files

9

Last publish

Collaborators

  • driimus