Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 19:17
    gkrinc commented #610
  • Jun 12 13:15
    kudla opened #741
  • Jun 11 10:48
    Travis db-migrate/node-db-migrate@341710f (dependabot/npm_and_yarn/glob-parent-5.1.2) passed (1167)
  • Jun 11 10:46
    Travis db-migrate/node-db-migrate@341710f (dependabot/npm_and_yarn/glob-parent-5.1.2) passed (1167)
  • Jun 11 10:44
    dependabot[bot] labeled #740
  • Jun 11 10:44

    dependabot[bot] on npm_and_yarn

    chore(deps): Bump glob-parent f… (compare)

  • Jun 11 10:44
    dependabot[bot] opened #740
  • Jun 11 02:11
    stale[bot] labeled #719
  • Jun 11 02:11
    stale[bot] labeled #718
  • Jun 11 02:11
    stale[bot] labeled #726
  • Jun 11 02:11
    stale[bot] labeled #729
  • Jun 11 02:11
    stale[bot] labeled #728
  • Jun 11 02:11
    stale[bot] labeled #730
  • Jun 11 02:11
    stale[bot] labeled #731
  • Jun 11 02:11
    stale[bot] labeled #733
  • Jun 11 02:11
    stale[bot] commented #719
  • Jun 11 02:11
    stale[bot] commented #718
  • Jun 11 02:11
    stale[bot] commented #726
  • Jun 11 02:11
    stale[bot] commented #729
  • Jun 11 02:11
    stale[bot] commented #728
Hi! i was wondering how to create a migration script, with default value using the literal DEFAULT_TIMESTAMP of mysql. i tried to search the docs & repo for ways to do this, but can't find any. can anyone help me please? Thanks!
Tobias Gurtzick
@shierro depends on the driver. in doubt new String('xyz') always works
in updated drivers such as the cockroachdb one there is a new raw property
in those you can write it like this:
    createdAt: {
      type: 'timestamptz',
      notNull: true,
      defaultValue: {
        raw: 'CURRENT_TIMESTAMP()'
if i am right this needs to be added to the other official drivers though. in that case fall back to new String
and you mean probably CURRENT_TIMESTAMP and not DEFAULT_TIMESTAMP
this is natively supported by the mysql driver anyway
just put it like that defaultValue: 'CURRENT_TIMESTAMP'
new String and raw will be more cross compatible in doubt though
ah yes, i was looking for the raw option, and yes for CURRENT_TIMESTAMP thanks @wzrdtales you're awesome
this is useful. although i haven't been able to see it in the docs. might be good if we can add it there for future reference
Tobias Gurtzick
np, it is not yet in the docs, and not yet in all drivers
I intend to add a special property as well
where I can put well known functions like current_timestamp across the board
and keep raw for the unique stuff
Hi. I'm getting an error [ERROR] Error: Environment(s) 'all' not found. My database.json file just contains one line: {
"all": {"ENV":"DATABASE_URL"}
}. Can you assist?
This is only happening within a Heroku release, not locally
and using command: db-migrate up --config config/database.json -e all
Tobias Gurtzick
you're using that wrong
first of all never name your target config all
all is a reserved key in a lot of cases
second of all, when you want to use DATABASE_URL you do not need any db config at all normally
and the error happens b/c the environment variable is not set
you need to check on your side why
Dmitry Dzhus
Hey all, I can't find anything on the status of COPY support – is it expected to work if I want to manage some custom data in migrations too? currently getting this on 0.11.5:
received data: CREATE TABLE test_data (col1 text, col2 text);

COPY test_data (col1, col2) FROM stdin;
a       b
c       d

[ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: syntax error at or near "a"

guys stupid question about installation
i am confused...
npm install -g db-migrate - done
creating the migration: db-migrate create initial

and the result is like this

'use strict';

var dbm;
var type;
var seed;

  * We receive the dbmigrate dependency from dbmigrate initially.
  * This enables us to not have to rely on NODE_PATH.
exports.setup = function(options, seedLink) {
  dbm = options.dbmigrate;
  type = dbm.dataType;
  seed = seedLink;

exports.up = function(db) {
  return null;

exports.down = function(db) {
  return null;

exports._meta = {
  "version": 1

this is definitely not the same as in docs
and i think its from another package at all
or... docs are a little bit wrong?

hello all! I am new to using db-migrate. I am needing some help with a small ..error? I'm getting a reply that require db-migrate-mongodb and ./mongodb are needed I believe. I can supply the full return if needed. This is all coming from the verbose print btw
@taburetkin I believe the docs are at least a few minor releases behind. That is my suspicion anyways.
Eduardo Tamaki
Hi, Is there a way to generate a migration file for the current database?
Hey There, does any of you know how to set a default decimal place for decimal data type inside of the exports.up variable?
I have done like "column_name { type: 'decimal', length: '10,2'}" and "column_name {type:'decimal', precision: 10, scale: 2}"
But none of these works...
hi guys
can you point me to examples of this framework please?
Josh Ydenberg

Hi Guys, I am getting an error only when using sync down() in a scoped environment.
I am using the programmable API and a driver i am developing to support another DB System.

Every other command seems to work fine, including syncing up migrations.
When the sync down parses the path from the migrations listed in the DB, it has the

issue that the directory and the name (which includes the subfolder), get appended.
Say my scope is "stores" the directory it is trying to access appends the scope name and becomes "/mypath/stores/stores/migrationName.js" instead of "/mypath/stores/migrationName.js". The scope name is already included in the migration table name, and seems expected int he migrator file.
Did i implement something wrong in my driver? every other operation seems to work, sync using scope up works, and sync down with no scope works - just this edge case is broken.
Josh Ydenberg

Under the "migration.js" file (db-migrate/lib/migration.js), there is the "loadFromDatabase" function. the dir parameter which is passed in already had the scope appended, but then it is also retreived in the name returned by the db. Then of course it fails with a "module cannot be found" error since the filepath is incorrect.
Is this a generic bug or is my driver implementation wrong?

For example ->
i run sync("20200110", "myscope)
Dir parameter passed in is "a/b/c/migrations/myscope" when i r
Migration is retreived myscope/mymigration
They get appended and it defines the path as "a/b/c/migrations/myscope/myscope/mymigration", which throws an error.

Is there a workaround for this or someway for up/down by date to work with the API?

Josh Ydenberg
Any ideas about above? Still seeing this issue
W. Matthew Wilson
Hey all: db-migrate looks nice because I want to write migrations in SQL. I'm trying to write a trivial, first migration, and db-migrate is fussing when I run $ npx db-migrate create; because I didn't make a .json file. For just creating a migration, do I need to make that .json file first? Is there a CLI flag to say "don't look for the .json file?"
Hariharan Narayanan
@at1217 : Don't know if you were able to solve how to set a default decimal place for decimal data type but I faced the same issue and this solved it - column_name {type:'decimal', precision: 10, scale: 2}. Do check out the example code in db-migrate/mysql in the file test/mysql_test.js.
Mikhail Dikov
Are there any known issues of running db-migrate on node 12?
Kyle Sykes

Looking back at the old conversation above around defaultValue and CURRENT_TIMESTAMP(3), I'm able to get it to work with a createTable statement, but cannot for the life of me get it to work with a changeColumn statement. I'm using postgres and it looks like the pg driver supports both raw and special statements according to the tests. I have the latest 1.2.2 version of db-migrate-pg, and here's my migration statement looks like:

  await db.changeColumn("my_table", "my_column", {
    type: "timestamp",
    timezone: true,
    defaultValue: {
      raw: "CURRENT_TIMESTAMP(3)",

Using --dry-run it generates an invalid SQL statement: ALTER TABLE "cms_case" ALTER COLUMN "created_at" SET DEFAULT { raw: 'CURRENT_TIMESTAMP(3)' };. And the error that's thrown is [ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: syntax error at or near "{". Am I missing something obvious? Or is this only valid for createTable and not changeColumn?

Daniil Sharko
Hi guys, please explain to me how to use the insert function?
i have simple table with 2 columns, id and name, how insert data into this table?
db.insert('agglomeration', ['name'], ['data1', 'data2'])?
or for id column also add number?
Hi folks, i want to excute migrations from a migrations folder. the migrations are written in sql. I want to do that on the app startup. any example for that
thank you
Francisco Palomares
Hi, how to execute migrations by schema ? Thanks