GithubHelp home page GithubHelp logo

sails-migrations's Introduction

THIS PROJECT IS LOOKING FOR A MAINTAINER

unfortunatly i do not have the time to support this project. so, please help :)

sails-migrations

NPM version Dependency Status Code Climate Build Status

sails-migrations provides an easy way to manage database migrations with sails, based on the amazing https://github.com/tgriesser/knex lib. This means you can have fine-grained control over your schema/data transformations between versions.

Supported sails versions:

sails-migrations supports sails versions 0.9X up to 0.11.2, for both MySQL & PostgreSQL.

Please let us know if you encounter any problem working with sails-migrations by opening an issue.

As of version 2.0 we've moved to using knex schema builder.

NOTE

  • sails-migrations up until (including) 0.1 supported Sails versions 0.9 & 0.10RC8

  • When upgrading to 2.0, notice that you'll need to change your old migrations code to work with knex instead of waterline.

What db migrations are and how/when to use them:

DB migrations allows you to change your database schema/data in a controlled way by making small atomic/ordered data to your DB, for a better answer, read this

Installing:

First run

npm install -g sails-migrations

this will install the global CLI sails-migrations.

Next you'll need to install sails-migrations within the project you would like to work on:

npm install --save sails-migrations

Usage

Fairly simple, there are a few basic commands

  • db:drop - Just as the name suggests, reads your sails config, and DROPS the db. use with care.
  • db:create - Same but different, creates the db you specified in your sails config.
  • generate <name> - Generate a new blank migrations file, after you run this command, you need to open the new file, which by default is saved to \db\migrations\, after you run this command, you should open this file, and put your migration information. for the migration syntex, please refer to the Knex documentation
  • migrate - Runs all the not-yet-runned migrations from the last run of migrate, all of those migrations are saved as a batch.
  • rollback - Runs the revert function on each migration in the last batch.
  • status - Prints a nice table of all the committed/uncommitted migrations.

Example apps

You can checkout some example Sails apps.

Commands

For a list of commands, simply run sails-migrations from your command prompt.

Working with migrations

For a more detailed documentation, please refer to http://knexjs.org/ A migration constitutes of two parts:

  • up: determines what should be performed when you want to forward your database to this version.
  • down: should be the exact reverse of the up method, so, for example, if on the up phase you created a table, the down phase should delete that table.

sails-migrations's People

Contributors

alubbe avatar bakavic avatar bluehotdog avatar enkows avatar itayadler avatar javm avatar joaosa avatar kmcgrath avatar marekkalnik avatar mattgstevens avatar particlebanana avatar rwoverdijk avatar simonstre 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar

sails-migrations's Issues

db:create fall in task 'createVersionTable

Run

grunt db:create -v

//console output
Running "db:setup" task

Running "db:loadConfig" task

Running "db:createVersionTable" task
Verifying property migration.config exists in config...OK
Creating version table
Warning: Invalid connection name specified Use --force to continue.

But the Database is created.

Use Sails.js 0.10.4, sails-mysql 0.10.6

Won't work for Heroku app.

Maybe I'm wrong about this entirely, but I believe db:create requires that it be able to create a new database, rather than just a new table. On Heroku, with the basic Postgresql DB, you can't create a new database, only new tables.

How to migrate when running sails lift?

How can we integrate this project with sails so migrations run when we run sails lift?

I tried setting this in config/bootstrap.js:

var sailsMigrations = require('sails-migrations');

module.exports.bootstrap = function(cb) {

    console.log('Performing Database Migrations');
    sailsMigrations.migrate();

    // It's very important to trigger this callback method when you are finished
    // with the bootstrap!  (otherwise your server will never lift, since it's waiting on the bootstrap)
    cb();
};

but I get these errors:

error: The bootstrap function threw an error after its callback was called :: TypeError: Cannot read property 'http' of undefined
    at Sails.getHost (/Users/josh/src/project/node_modules/sails/lib/app/private/getHost.js:11:43)
    at Sails.bound [as getHost] (/Users/josh/src/project/node_modules/lodash/dist/lodash.js:729:21)
    at Sails.getBaseurl (/Users/josh/src/project/node_modules/sails/lib/app/getBaseurl.js:19:20)
    at Sails.bound [as getBaseurl] (/Users/josh/src/project/node_modules/lodash/dist/lodash.js:729:21)
    at _printSuccessMsg (/Users/josh/src/project/node_modules/sails/lib/app/lift.js:63:56)
    at sailsReady (/Users/josh/src/project/node_modules/sails/lib/app/lift.js:43:5)
    at /Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:251:17
    at /Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:154:25
    at /Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:248:21
    at /Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:612:34
    at afterBootstrap (/Users/josh/src/project/node_modules/sails/lib/app/private/initialize.js:57:5)
    at bootstrapDone (/Users/josh/src/project/node_modules/sails/lib/app/private/bootstrap.js:51:14)
    at Object.module.exports.bootstrap (/Users/josh/src/project/config/bootstrap.js:22:2)
    at Sails.runBootstrap (/Users/josh/src/project/node_modules/sails/lib/app/private/bootstrap.js:44:25)
    at Sails.bound [as runBootstrap] (/Users/josh/src/project/node_modules/lodash/dist/lodash.js:729:21)
    at Sails.initialize (/Users/josh/src/project/node_modules/sails/lib/app/private/initialize.js:48:9) [TypeError: Cannot read property 'http' of undefined]
/Users/josh/src/project/node_modules/sails/lib/hooks/cors/index.js:113
        if (sails.config.cors.securityLevel > sails.hooks.cors.SECURITY_LEVEL_NORMAL) {
                                                              ^

TypeError: Cannot read property 'SECURITY_LEVEL_NORMAL' of undefined
    at Sails.<anonymous> (/Users/josh/src/project/node_modules/sails/lib/hooks/cors/index.js:113:63)
    at emitNone (events.js:72:20)
    at Sails.emit (events.js:166:7)
    at Sails.emitter.emit (/Users/josh/src/project/node_modules/sails/lib/app/private/after.js:50:11)
    at Router.flush (/Users/josh/src/project/node_modules/sails/lib/router/index.js:336:9)
    at Router.bound (/Users/josh/src/project/node_modules/lodash/dist/lodash.js:729:21)
    at Router.load (/Users/josh/src/project/node_modules/sails/lib/router/index.js:115:8)
    at Array.bound (/Users/josh/src/project/node_modules/lodash/dist/lodash.js:729:21)
    at listener (/Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:490:46)
    at /Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:441:17
    at _each (/Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:46:13)
    at Immediate.taskComplete (/Users/josh/src/project/node_modules/sails/node_modules/async/lib/async.js:440:13)
    at processImmediate [as _immediateCallback] (timers.js:368:17)

Auto-generate migrations for models

A new feature that I think might be useful for sails migrations:

The ability to auto-generate a migration based on a model file. It wouldn't consistently auto-generate migrations for changes, as this seems like it would be difficult and require managing state. The thought is more of a one-time per model time saver. You define your model then call:
sails-migrations generate:model [name of model]
It then parses the model file and creates a migration file based on that model. It doesn't have to parse everything in attributes, if there is some non-standard or in-depth attribute we can just rely on the user updating the migration file to handle that attribute. In my mind the low hanging fruit are:

  • Table Names
  • Column Names
  • Types
  • Required (though waterline ignores this in auto-migrations, so maybe we should too)
  • Unique
  • Simple relations (make them integers)
  • More complex relations (Too difficult without having context on both models?)

I'm happy to take a hack at it, but it will just be weekend time which itself is a bit limited right now for me.

When using url connection declaration improper db name

If using url: 'postgresql://user:pw@localhost:5432/dbName?ssl=false' in connections.js

There is an error when attempting to connect to the database. It is attempting to connect to 'dbName?ssl=false' instead of dbName, I believe there should be a handler in place to check for the query ssl.

infinite process

I am tring to use sails-migration and it does not work and i dont have any error. The grunt task just proceed infinitly.

here is my input when i try db:create

Running "db:loadConfig" task
js-bson: Failed to load c++ bson extension, using pure JS version

Running "db:createInternalTask" task
Trying to create a new database

postgres db:reset not working, other connections accessing

Seems that my grunt or something in sails is creating a bunch of connections before the reset tries to run and therefore the reset cannot complete. To me, it looks like sails is being run and creating 6 connections (that is what it complains about) to my 6 models, before the db:reset tries to happen.

Support for waterline 0.10.0

Do you have a plan to develop sails-migrations for waterline 0.10.0? On 'rc' version actually i have this error:

npm ERR! peerinvalid The package sails does not satisfy its siblings' peerDependencies requirements!

Thanks!

`db:create` fails

I'm setting up my initial app and trying to create the initial empty database, and it's failing when running grunt db:create

bloggy$ grunt db:create
Running "db:loadConfig" task
Error creating a connection to Postgresql: error: database "bloggy_develpment" does not exist
Error creating a connection to Postgresql: error: database "bloggy_develpment" does not exist
error: Hook failed to load: orm (error: database "bloggy_develpment" does not exist)
error: Error encountered while loading Sails core!
error: error: database "bloggy_develpment" does not exist
    at Connection.parseE (/Users/jeremy/Sites/bloggy/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:561:11)
    at Connection.parseMessage (/Users/jeremy/Sites/bloggy/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:390:17)
    at null.<anonymous> (/Users/jeremy/Sites/bloggy/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:98:18)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:748:14)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:410:10)
    at emitReadable (_stream_readable.js:406:5)
    at readableAddChunk (_stream_readable.js:168:9)
    at Socket.Readable.push (_stream_readable.js:130:10)
Warning: database "bloggy_develpment" does not exist Use --force to continue.

Aborted due to warnings.

"version": "0.0.4" with sails 0.9.16

UPDATE
I added the grunt.loadNpmTasks('gake') to my Gruntfile.js, so it no longer fails, but it sits there during Running "db:loadConfig" task and does nothing. I let it run for several minutes. It seems any grunt command I do now just hangs. I'm not sure if I need to run that loadNpmTasks('gake') or not. The instructions on https://www.npmjs.org/package/sails-migrations don't mention it.

can't install ??

When running 'sudo npm install sails-migrations -g':

npm ERR! Error: ENOENT, chmod '/usr/lib/node_modules/sails-migrations/bin/cli.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 3.13.0-30-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "sails-migrations" "-g"
npm ERR! cwd /home/vagrant/sails
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/lib/node_modules/sails-migrations/bin/cli.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! not ok code 0

Note: I run this within a vagrant box where sails is up and running

db:create not working for postgresql

I can't figure out a way to make db:create work on Postgresql.

I am running on Ubuntu, installed postgres using the standard apt-get package and have configured it to allow md5 login and gave my user (alvaro) permissions to create databases.

The database does get created, the process fails on creating the version table.

This is the error:

alvaro: (master) ~/Projects/SailsTestProject$ grunt db:create
Running "db:loadConfig" task

Running "db:createInternalTask" task
Trying to create a new database
Password: 
>> Database created successfully

Running "db:createVersionTable" task
Creating version table
Warning: undefined is not a function Use --force to continue.

Aborted due to warnings.

By tracking this down, I believe it's happening on line 29 of the schema_migration.coffee file: "new SchemaMigration(options, cb)"

I am using "sails": "~0.10.2" which might not be supported.

Any clues onto what could be done here would be greatly appreciated.

I did get a repo up what has the problem just in case: https://github.com/oliveiraa/sails-migrations-test

Thanks,

Alvaro Oliveira.

drop/create only works on mysql

Currently drop/create works in a weird way, of executing a special query against the db directly, without using waterline(since waterline does not support that yet).

Simple table creation migration does not create table

Running the following migration creates the sails_migrations table, adds a row to it, but does not create the inventoryAccounts table. Perhaps I'm missing something obvious...

'use strict';

exports.up = function(knex, Promise) {
  knex.schema.createTable('inventoryAccounts', function (table) {
    table.increments();
    table.text('name');
    table.text('slug');
    table.boolean('allowNegativeBalance');
  });
};

exports.down = function(knex, Promise) {
  knex.schema.dropTable('inventoryAccounts');
};

Verifying property migration.config exists in config

Hello

Can't make it work, Getting following error. Do I need to create some config file to get started? Any help will be appreciated. Thanks

codevarun@ubuntu:/var/www/botrovert$ grunt migration:generate --name="my migration name" --force -v
Initializing
Command-line options: --name=my migration name, --force, --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.

Registering "node_modules/sails/node_modules/grunt-contrib-clean/tasks" tasks.
Loading "clean.js" tasks...OK
+ clean

Registering "node_modules/sails/node_modules/grunt-contrib-copy/tasks" tasks.
Loading "copy.js" tasks...OK
+ copy

Registering "node_modules/sails/node_modules/grunt-contrib-concat/tasks" tasks.
Loading "concat.js" tasks...OK
+ concat

Registering "node_modules/sails/node_modules/grunt-sails-linker/tasks" tasks.
Loading "scriptlinker.js" tasks...OK
+ sails-linker

Registering "node_modules/sails/node_modules/grunt-contrib-jst/tasks" tasks.
Loading "jst.js" tasks...OK
+ jst

Registering "node_modules/sails/node_modules/grunt-contrib-watch/tasks" tasks.
Loading "watch.js" tasks...OK
+ watch

Registering "node_modules/sails/node_modules/grunt-contrib-uglify/tasks" tasks.
Loading "uglify.js" tasks...OK
+ uglify

Registering "node_modules/sails/node_modules/grunt-contrib-cssmin/tasks" tasks.
Loading "cssmin.js" tasks...OK
+ cssmin

Registering "node_modules/sails/node_modules/grunt-contrib-less/tasks" tasks.
Loading "less.js" tasks...OK
+ less

Registering "node_modules/sails/node_modules/grunt-contrib-coffee/tasks" tasks.
Loading "coffee.js" tasks...OK
+ coffee
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK

Registering "sails-migrations" local Npm module tasks.
Reading /var/www/botrovert/node_modules/sails-migrations/package.json...OK
Parsing /var/www/botrovert/node_modules/sails-migrations/package.json...OK
Loading "db.coffee" tasks...OK
+ db:create, db:createInternalTask, db:drop, db:dropInternalTask, db:reset
Loading "db:generate.coffee" tasks...OK
+ migration:generate, migration:generateInternalTask
Loading "db:migrate.coffee" tasks...OK
+ db:migrate, db:migrateTask, db:rollback, db:rollbackTask
Loading "db:status.coffee" tasks...OK
+ db:status, db:status:validateTableExists, db:statusTask
Loading "helpers.coffee" tasks...OK
>> No tasks were registered or unregistered.
Loading "load_config.coffee" tasks...OK
+ db:loadConfig
Loading "Gruntfile.js" tasks...OK
+ build, compileAssets, default, linkAssets, prod

Running tasks: migration:generate

Running "migration:generate" task

Running "db:loadConfig" task

Running "migration:generateInternalTask" task
Verifying property migration.config exists in config...Warning: Maximum call stack size exceeded Used --force, continuing.

Done, but with warnings.

Environment information not properly propagated through to configuration loading

In attempting to migrate new changes into the production DB for the first time, it was realized that the environment information isn't handled properly.

A workaround for the issue is:

NODE_ENV=production sails-migrations migrate

The issue appears to be that the configuration pulls in the default configuration under the assumption that the environment is development, not production, despite whether or not someone is using the '--env' flag. This was confirmed by running the following script to print out what the application is seeing:

const SailsIntegration = require('./node_modules/sails-migrations/lib/sails-migrations/helpers/sails_integration');
const path = require('path');

var modulesPath = path.join(process.cwd(), 'node_modules');
SailsIntegration.loadSailsConfig(modulesPath, function(err, cache) {
  console.log(cache);
});

For me, this was resulting in a connection refused error (ECONNREFUSED).

db:migrate doesn't work

I've followed carefully the docs from this version:
https://github.com/BlueHotDog/sails-migrations/tree/v0.10

I run:

albert$ grunt migration:generate --name="test"

And I get:

/*
* Sails migration
* Created at 2014-11-22T21:48:17+00:00
* */

exports.up = function(adapter, done) {
    console.log('Yo!');
 done();
};

exports.down = function(adapter, done) {
  done();
};

Then I run and get:

albert$ grunt db:migrate
Running "db:loadConfig" task

Running "db:migrateTask" task
Warning: undefined is not a function Use --force to continue.

Aborted due to warnings.

Following exact steps from the docs. Do you know what could be wrong?

More things I tried:

grunt db:create
Running "db:loadConfig" task

Running "db:createInternalTask" task
Trying to create a new database
Fatal error: Error: Command failed: createdb: database creation failed: ERROR:  database "albert" already exists

albert$ grunt db:status
Running "db:loadConfig" task

Running "db:status:validateTableExists" task
Checking if sails_schema_migrations exists
Warning: undefined is not a function Use --force to continue.

Aborted due to warnings.

Rails-like Migration Interface

instead of:

exports.up = (adapter, done) ->
  adapter.drop('myTable', done);
  done()

exports.down = (adapter, done) ->
  # ...
  done()

I would prefer to do:

class ICanHasMigration extends SailsMigration

  up: ->
    @drop('myTable')

  down: ->
    # ...


class SailsMigration

   initilize: (adapter, done_cb)->   

   handle_up: ->
       # delegate all calls to adapter and append the done_cb as the last argument
   handle_down: -> 
       #....

npm install depends on postgresql path export

Not sure what's going on here but every other module installs perfectly on my setup. I use nvm.

albert$ npm install -g sails-migrations
/
> [email protected] install /usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/node_modules/pg
> node-gyp rebuild || (exit 0)

/bin/sh: pg_config: command not found
gyp: Call to 'pg_config --libdir' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpEx (/usr/local/Cellar/nvm/0.17.2/v0.10.32/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/Cellar/nvm/0.17.2/v0.10.32/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/Cellar/nvm/0.17.2/v0.10.32/lib/node_modules/sails-migrations/node_modules/pg
gyp ERR! node -v v0.10.32
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm ERR! Error: ENOENT, chmod '/usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/bin/cli.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.4.0
npm ERR! command "/usr/local/opt/nvm/v0.10.32/bin/node" "/usr/local/opt/nvm/v0.10.32/bin/npm" "install" "-g" "sails-migrations"
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/bin/cli.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! not ok code 0

Once I do an export of the postgresql path, I get these:

albert$ npm install -g sails-migrations

> [email protected] install /usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/node_modules/pg
> node-gyp rebuild || (exit 0)

CXX(target) Release/obj.target/binding/src/binding.o
SOLINK_MODULE(target) Release/binding.node
SOLINK_MODULE(target) Release/binding.node: Finished
npm ERR! Error: ENOENT, chmod '/usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/bin/cli.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.4.0
npm ERR! command "/usr/local/opt/nvm/v0.10.32/bin/node" "/usr/local/opt/nvm/v0.10.32/bin/npm" "install" "-g" "sails-migrations"
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/opt/nvm/v0.10.32/lib/node_modules/sails-migrations/bin/cli.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! not ok code 0

How to start using the current version?

The docs are not to explanatory about how to start using and examples (broken link).

I've manually downloaded and installed (npm broken) the latest version but I wonder if you could throw a line or two about how to actually use it?

Thank you

Usage examples

Please, provide a few examples of usage of your plugin. Link in README file is outdated

DB create fails with "error in your SQL syntax"

Just did a clean install

vagrant@vagrant-ubuntu-trusty-64:/vagrant/server$ sails --version
0.11.0

vagrant@vagrant-ubuntu-trusty-64:/vagrant/server$ sails-migrations --version
sails_migrations CLI version:  2.0.7
Local sails_migrations version:  2.0.7

vagrant@vagrant-ubuntu-trusty-64:/vagrant/server$ sails-migrations db:create
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"myDbName"' at line 1
    at Query.Sequence._packetToError
  developmentMysqlServer: {
    adapter: 'sails-mysql',
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'api'
  },

Breaks on Ubuntu 14.04

On Ubuntu 14.04, I get the following...

root@f32dcd67fa99:/app# npm install sails-migrations
npm ERR! tar.unpack untar error /root/.npm/sails-migrations/2.0.7/package.tgz
npm ERR! Linux 4.0.9-boot2docker
npm ERR! argv "node" "/usr/bin/npm" "install" "sails-migrations"
npm ERR! node v0.12.7
npm ERR! npm  v3.3.3
npm ERR! path /app/node_modules/.staging/sails-migrations-8f658b2f782b7fad6532770007846687/tasks/db:status.coffee
npm ERR! code EPROTO
npm ERR! errno -71

npm ERR! EPROTO, open '/app/node_modules/.staging/sails-migrations-8f658b2f782b7fad6532770007846687/tasks/db:status.coffee'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /app/npm-debug.log

Turns out, I get a similar error (EPROTO) if I do the following...

root@f32dcd67fa99:/app# tar -xvf /root/.npm/sails-migrations/2.0.7/package.tgz
package/package.json
package/README.md
package/LICENSE
package/index.js
package/bin/cli.js
package/bin/run_tests.js
package/lib/sails-migrations.js
package/lib/sails-migrations/create_database.js
package/lib/sails-migrations/current_version.js
package/lib/sails-migrations/drop_database.js
package/lib/sails-migrations/errors.js
package/lib/sails-migrations/generate.js
package/lib/sails-migrations/migrate_to_latest.js
package/lib/sails-migrations/rollback.js
package/lib/sails-migrations/status.js
package/lib/sails-migrations/helpers/config_loader.js
package/lib/sails-migrations/helpers/database_tasks.js
package/lib/sails-migrations/helpers/migrator_loader.js
package/lib/sails-migrations/helpers/sails_integration.js
package/tasks/db:status.coffee
tar: package/tasks/db\:status.coffee: Cannot open: Protocol error
tar: Exiting with failure status due to previous errors

Not exactly sure why this is happening.

liftoff 2x / v8flags 2x released

Heya, this is just a friendly note to let you know that a new version of Liftoff and some of the dependencies commonly used in conjunction with it have been released. This release adds better support for situations where your user's configuration files are written using features behind a v8 flag (e.g. --harmony). Windows users and io.js users should see less issues if you upgrade!

Some helpful links:
https://github.com/tkellen/node-liftoff/blob/master/UPGRADING.md#100---200
https://github.com/tkellen/node-v8flags/blob/master/README.md#example
https://github.com/tkellen/node-hacker/blob/master/bin/hacker.js#L10-L14

Thanks!

table.timestamps() creates unusable column names

This is more a knex issue than sails-migrations issue, but wanted to have the issue documented for future users. http://knexjs.org/#Schema-timestamps

Issue:

table.timestamps() creates created_at and updated_at while sails is expecting createdAt and updatedAt

Resolutions:

  1. If you haven't yet used table.timestamps():
table.timestamp('createdAt');
table.timestamp('updatedAt');
  1. If you've already used table.timestamps():

Create a migration for fixing the erroneous columns (sails-migrations generate fix_timestamps)

'use strict';

exports.up = function(knex, Promise) {
  function renameUp(table) {
    table.renameColumn('created_at', 'createdAt')
    .renameColumn('updated_at', 'updatedAt');
  }

  Promise.all([
    knex.schema.table('myTable', renameUp)
  ]);
};

exports.down = function(knex, Promise) {
  function renameDown(table) {
    table.renameColumn('createdAt', 'created_at')
    .renameColumn('updatedAt', 'updated_at');
  }

  Promise.all([
    knex.schema.table('myTable', renameDown)
  ]);
};

db:create error ( Heroku with Postgresql )

I'm trying to use migration for my app which is lifted on heroku.

I've installed sails-migrations and trying to create db.
I got this error when I trying create db here...and I don't know what I should do..
Is there any help?? TT

grunt db:create
>> Tasks directory "./grunt/tasks" not found.

Running "db:loadConfig" task

Running "db:createInternalTask" task
Trying to create a new database
Fatal error: Command failed: createdb: could not connect to database template1: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I'm using [email protected] [email protected].
Thanks.

Helping maintain this module

@BlueHotDog Danni, as you probably remember, we're using sails-migrations in production at Treeline. I think we still need to find someone who can help push the project further forward (e.g. as far as documentation), but I'd like to offer to help if we can in the mean time in the case of any immediate term emergencies or bugs that come up.

I'd also like to see manual migrations make their way into the Sails core CLI in the future. This would need to be specced out further into a proper proposal, and I think the first step to getting there is for more folks to start using this module (hopefully incorporating ideas from sails-db-migrate).

So in the mean time, please feel free to ping any of the Sails core team on Twitter for any high-priority patches in sails-migrations and we'll do our best to help. Thanks everyone!

Migration succeeds but I receive an error

When I attempt to migrate it succeeds in creating my table but outputs an error at the command line. The error and the code for my migration are below.

error

Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
    at SchemaBuilder_PG.Target.then (../node_modules/sails-migrations/node_modules/knex/lib/interface.js:27:33)

migration

'use strict';

exports.up = function(knex, Promise) {
  return knex.schema.createTable('user', function (table) {
    table.increments();
      table.datetime('createdAt');
      table.datetime('updatedAt');
    })
};

exports.down = function(knex, Promise) {
  return knex.schema.dropTable('user');
};

npm install fails with ENOENT

Perhaps a similar problem to #41

I get the following output when doing an npm install:

~$ npm install sails-migrations
-
> [email protected] install /Users/pivotal/node_modules/sails-migrations/node_modules/pg
> node-gyp rebuild || (exit 0)

  CXX(target) Release/obj.target/binding/src/binding.o
  SOLINK_MODULE(target) Release/binding.node
  SOLINK_MODULE(target) Release/binding.node: Finished
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "sails-migrations"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.8
npm ERR! path /Users/pivotal/node_modules/sails-migrations/bin/cli.js
npm ERR! code ENOENT
npm ERR! errno 34

npm ERR! enoent ENOENT, chmod '/Users/pivotal/node_modules/sails-migrations/bin/cli.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/pivotal/npm-debug.log

And here's that log: https://gist.github.com/camelpunch/34afbb57f1d5ea3af488

Perhaps I've missed an installation step? Annoying that npm install won't tell me what's up apart from the missing file or dir.

db:create hangs with mongodb

db:create hangs with:

  grunt db:create
  Running "db:loadConfig" task

  Running "db:createInternalTask" task
  Trying to create a new database

verbose mode doesn't show additional info

Heroku Postgres connection string requires ssl param

When using Heroku Postgres with sails, you have to add a property for ssl:

  connections: {
    postgres: {
      url: 'postgres://CONNECTION_STRING',
      ssl: true
    }
   }

However, this does not work for sails-migrations. You have to explicitly add ssl to the connection string:

  connections: {
    postgres: {
      url: 'postgres://CONNECTION_STRING?ssl=true'
    }
  }

Support for sails v0.11

Hi! I'm trying to use this with sails v0.11. I've done really basic stuff so far without any problem. Do you know of any issue that may arise later on? Is the README to be updated (it indicates support up to 0.10.5)? Not sure whether the v0.10 to v0.11 upgrade has affected any of the aspects this lib relies on...

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.