GithubHelp home page GithubHelp logo

podiljs / podil Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 0.0 157 KB

Lightweight and secure database schema migration tool ๐ŸŽฏ

License: Apache License 2.0

TypeScript 100.00%
nodejs sql database javascript migration migration-tool postgres postgresql typescript

podil's Introduction

Podil Build Coverage Status npm version install size

Lightweight and secure database migration tool for Node.js and Postgres. Podil lets you version your database schema by executing SQL scripts automatically on application startup. It keeps track of what scripts have been executed and what not which lets you seamlessly update your database schema on every environment in the same way. Podil saves you from mistakingly breaking your schema by storing and verifying checksums of every script that it executed. Podil strives at being simple and minimalistic, that's why it brings no dependencies except for Podil itself.

How to use

Install Podil and pg:

npm install podil pg

Create a migrations folder in the folder from which you start your application (usually the project root) and add .sql scripts to it.

.
โ”œโ”€โ”€ migrations
โ”‚   โ”œโ”€โ”€ 001__init_schema.sql
โ”‚   โ”œโ”€โ”€ 002__add_orders_table.sql
โ”‚   โ””โ”€โ”€ 003__add_order_status_column.sql

In the code, import podil:

import { podil } from 'podil';

Add the migration call at the entry point of your application:

await podil.migrate('postgres://podil:podil@localhost:5432/podil');

This will execute all migrations. Note, the SQL files will be executed in the lexicographical order.

Configuration

Podil can be configured to look for migration scripts in an arbitrary location. By default, it looks for migrations in ./migrations, you can pass a custom folder in the following way:

await podil.migrate(
    connectionString,
    { migrationsDir: '/path/to/your/migrations' },
);

It is recommended to verify the checksums of your scripts on every run. However, you can disable checksum verification using the verifyChecksum property:

await podil.migrate(
  connectionString,
  { verifyChecksum: false },
);

Troubleshooting

Podil is in active development. If you found a bug, have a question or want to request a new feature, please open an issue.

podil's People

Contributors

shpota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

podil's Issues

Create a better logo

The Podils logo is very simple due to my lack of SVG knowledge. I would consider other options

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.