GithubHelp home page GithubHelp logo

Comments (17)

BlueHotDog avatar BlueHotDog commented on September 7, 2024

Hi Kavin, thanks for the report, will take a look(and fix) during the
weekend :)

You're more then welcome to also try and fix and submit a PR :) (we dont
bite)

On Tue Feb 03 2015 at 11:13:21 PM Kevin OBrien [email protected]
wrote:

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');
};


Reply to this email directly or view it on GitHub
#54.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

I'm happy to give it a shot, I'll carve out some time Friday to take a look.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

I found a bit of time for this tonight, but I'm honestly not quite sure how to parse what I'm finding as of yet. I'll plan on dedicating some more time on this Friday and this weekend, I'd really like to help! Also below is the full stack trace of the error instead of the two lines I gave you above.

Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
    at SchemaBuilder_PG.Target.then (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/interface.js:30:33)
    at SchemaBuilder_PG.Target.(anonymous function) [as bind] (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/interface.js:76:21)
    at Migrator_PG.<anonymous> (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:121:6)
From previous event:
    at Migrator_PG.<anonymous> (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:166:15)
From previous event:
    at Migrator_PG.Migrator._migrationData (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:182:10)
    at Migrator_PG.<anonymous> (/Users/kevin/code/fikes/api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:50:15)
From previous event:
    at /Users/kevin/code/fikes/api/node_modules/sails-migrations/lib/sails-migrations/migrate_to_latest.js:12:23
    at process._tickCallback (node.js:442:13)

from sails-migrations.

BlueHotDog avatar BlueHotDog commented on September 7, 2024

Hi Kavin, i dont see anything wrong with your code,
is there a chance to take a look at the actual code?

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Absolutely. Here is a repo in which I can successfully re-create the error by running "sails-migrations migrate". It's a brand new sails app with only database config, model config to turn off auto-migrations and a user api to match the user table migration I made.

https://github.com/kevinob11/sails-migrations-test

from sails-migrations.

BlueHotDog avatar BlueHotDog commented on September 7, 2024

Amazing, will check tomorrow!
On Sat, Feb 7, 2015 at 21:00 Kevin OBrien [email protected] wrote:

Absolutely. Here is a repo in which I can successfully re-create the error
by running "sails-migrations migrate". It's a brand new sails app with only
database config, model config to turn off auto-migrations and a user api to
match the user table migration I made.

https://github.com/kevinob11/sails-migrations-test


Reply to this email directly or view it on GitHub
#54 (comment)
.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Thanks! I'm happy to move this to another issue or non-github convo, but is the goal of this project in the long term to be able to auto generate migrations from model definitions in sails?

from sails-migrations.

BlueHotDog avatar BlueHotDog commented on September 7, 2024

the short answer is: no :)
the longer one is:
quite the contrary, you want your migrations to NEVER touch your models.
since models are committed via your source control, but your database/data isnt
the purpose of the migrations is to bring your database to the state you want it to be, through atomic operations, sometime this includes very complex transformations.(data migrations is only one of those)
so you want the operations to execute in the "exact" same order your wrote them.

It's not the purpose of db migrations to "keep the db in sync" with your models.
just think how scary is that with real, live data. imagine you drop a column with real data just because you removed it from the model.. really scary.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Yeah I get exactly what you mean, I would never expect migrations to do that and I see how that would be really scary with any live app.

What I had in mind though was more of a convenience feature. Not something you would use as the standard method of making database changes, more a one time use at the beginning of a project in order to reduce how much code you have to write. I picture it as: I build all of my models in sails, I then run "sails-migrations generate:model user", at which point sails-migrations generates a migration file that matches what you have in your user model, so you would still have a history of database changes in the migrations file, but you don't have to manually write it. You should of course check that file, and you would never use this feature for additional changes to a model, just the initial build of it. Seems like it would save some time and help beginners make the change to a migration tool rather than rely on sails auto migrations, which always seem like a dangerous "magical" feature to me.

If the answer is that this introduces a lot of danger and confusion for something that adds only a little convenience, I get it. It just seemed like something that might be valuable.

One more question that doesn't belong in this issue thread: Besides pulling connector config from Sails what additional features does this project add above and beyond just using knex to handle your migrations? To be clear, I think that is plenty worthwhile, I was just considering making the switch and I want to make sure I'm making an informed decision.

Thanks!

from sails-migrations.

BlueHotDog avatar BlueHotDog commented on September 7, 2024

regarding point no.1: seems like a nice feature, but involves quite a lot of debugging, i'm extremely busy currently, but please open a new issue with this feature so we can think and discuss this further. maybe i'll find one weekend to do this.

regarding point no.2: you're right, this is just a small npm that does about that :) although stuff will be added i guess. but the intention is just for this to be a glue between 2 good modules.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Great! I'll get a new issue opened this week, and I'd be happy to help work on it as well!

from sails-migrations.

JetFault avatar JetFault commented on September 7, 2024

+1, having same issue.

The sails_migrations table gets created, and all the migrations are run

EDIT: Heres the error being thrown

Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
  at SchemaBuilder_PG.module.exports.Target.then (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/interface.js:27:33)
  at SchemaBuilder_PG.module.exports._.each.Target.(anonymous function) [as bind] (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/interface.js:73:21)
  at Migrator_PG.<anonymous> (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:121:6)
From previous event:
  at Migrator_PG.<anonymous> (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:166:15)
From previous event:
  at Migrator_PG.Migrator._migrationData (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:182:10)
  at Migrator_PG.<anonymous> (/home/jerry/code/jobhero-api/node_modules/sails-migrations/node_modules/knex/lib/migrate/index.js:50:15)
From previous event:
  at module.exports (/home/jerry/code/jobhero-api/node_modules/sails-migrations/lib/sails-migrations/migrate_to_latest.js:10:23)
  at process._tickCallback (node.js:419:13)

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Not quite the same issue, as for me the migrations were properly run.

@BlueHotDog my apologies for not getting the new issue opened last week, I'm definitely still interested I'll make sure I don't lose track of it.

from sails-migrations.

JetFault avatar JetFault commented on September 7, 2024

@kevinob11 I edited my issue, migrations were being done, so same issue

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Ah missed the edit. Right-o then! Love to hear what you may be able to find. I had trouble tracking this down. Its a then on a promise deep in knex that is being called by sails-migrations without any params, I think.

from sails-migrations.

enkows avatar enkows commented on September 7, 2024

[email protected] fixed this issue.

from sails-migrations.

kevinob11 avatar kevinob11 commented on September 7, 2024

Great!

from sails-migrations.

Related Issues (20)

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.