title: How can I use node-pg-migrate with independent lanes of migrations?
body: <p>Currently, migration scripts (<a href="https://github.com/salsita/node-pg-migrate" rel="nofollow noreferrer">node-pg-migrate</a>) build the entire database from zero to everything. It's the database of a new system that is going to replace the legacy system. Data needs to be imported from the legacy system to the new database. They have completely different data structures.</p>
  
  <p>The migrations scripts build the <code>import</code> schema with raw data imported from the legacy system (using its web service). Then all other schemas with its tables, functions and everything is created. Primarily the <code>data</code> schema with data transformed from the <code>import</code> schema usable for the new system. The <code>api</code> schema with views and functions exposed through postgREST working on data from the <code>data</code> schema. And some more helper schemas and stuff.</p>
  
  <p>Now, the data to be imported is not final yet, so I need to re-import often. To do that, I need to migrate all the way down, dropping all other schemas as it goes down to get to the migration steps that remove all imported data and drops the <code>import</code> schema. Then go up again to import the data all the way up again to build all the schemas to have a working api again.</p>
  
  <p>I'm getting to my question now shortly... I'm quite sure I need to move the import data scripts away from the migration so I don't need to deconstruct and reconstruct the entire database and all its schemas. Ideally, I want to run import scripts and schema scripts independently. Using <code>node-pg-migrate</code> though is really convenient, also for importing the data.</p>
  
  <p>How can I use node-pg-migrate with independent lanes of migrations? One for imports (or dml changes) and one for schema changes (or ddl changes).</p>
  
  <p><em>Related:</em></p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/8809509/migration-scripts-for-structure-and-data">Migration scripts for Structure and Data</a></li>
  <li><a href="https://dba.stackexchange.com/questions/64632/how-to-create-a-versioning-ddl-dml-change-script-for-sql-server">https://dba.stackexchange.com/questions/64632/how-to-create-a-versioning-ddl-dml-change-script-for-sql-server</a></li>
  </ul>
  
  <p><em>Update: I just found out the solution may lie in the area of <a href="https://db-migrate.readthedocs.io/en/latest/Getting%20Started/commands/#scoping" rel="nofollow noreferrer">scope</a> as implemented by node-db-migrate</em>. I'm using <a href="https://github.com/salsita/node-pg-migrate" rel="nofollow noreferrer">node-pg-migrate</a> though...</p>