sequelize-pg-migrations
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

sequelize-pg-migrations

The intention of this package is to generate sequelize migration files for a postgres db automatically.

To do so:

npm install --save-dev sequelize-pg-migrations

Place .sequelizerc into your project's root folder and configure 'migrations-path'.

pg-diff-cli is used to generate sql statements. To make it properly work place pg-diff-config.json into your project's root folder. You must have forward and backward configurations in it.

{
  "forward": {
    "sourceClient": {
      "host": "localhost",
      "port": 5432,
      "database": "dbname",
      "user": "postgres",
      "password": "pass",
      "applicationName": "pg-diff-cli"
    },
    "targetClient": {
      "host": "target.host",
      "port": 5432,
      "database": "targetdb",
      "user": "postgres",
      "password": "pass",
      "applicationName": "pg-diff-cli"
    },
    "compareOptions": {
      "author": "",
      "outputDirectory": ".temp",
      "getAuthorFromGit": true,
      "schemaCompare": {
        "namespaces": ["public"],
        "dropMissingTable": true,
        "dropMissingView": true,
        "dropMissingFunction": true,
        "dropMissingAggregate": true,
        "roles": []
      },
      "dataCompare": {
        "enable": false
      }
    }
  },
  "backward": {
    "targetClient": {
      "host": "localhost",
      "port": 5432,
      "database": "dbname",
      "user": "postgres",
      "password": "pass",
      "applicationName": "pg-diff-cli"
    },
    "sourceClient": {
      "host": "target.host",
      "port": 5432,
      "database": "targetdb",
      "user": "postgres",
      "password": "pass",
      "applicationName": "pg-diff-cli"
    },
    "compareOptions": {
      "author": "",
      "outputDirectory": ".temp",
      "getAuthorFromGit": true,
      "schemaCompare": {
        "namespaces": ["public"],
        "dropMissingTable": true,
        "dropMissingView": true,
        "dropMissingFunction": true,
        "dropMissingAggregate": true,
        "roles": []
      },
      "dataCompare": {
        "enable": false
      }
    }
  }
}

To generate migrations run:

npx migen

Package Sidebar

Install

npm i sequelize-pg-migrations

Weekly Downloads

1

Version

1.0.12

License

MIT

Unpacked Size

20.5 kB

Total Files

13

Last publish

Collaborators

  • anton.nagornyi