ah-sequelize-plugin
Advanced tools
Comparing version 0.8.0 to 0.8.5
@@ -23,3 +23,3 @@ exports.default = { | ||
function merge(overlayFn) { | ||
var merge = function(overlayFn) { | ||
var mergeObj = {}; | ||
@@ -32,3 +32,3 @@ for (var attrname in exports.default.sequelize()) { mergeObj[attrname] = exports.default.sequelize()[attrname]; } | ||
return mergeObj; | ||
} | ||
}; | ||
@@ -35,0 +35,0 @@ // You can define even more elaborate configurations (including replication). |
@@ -7,2 +7,6 @@ var path = require('path'); | ||
module.exports = { | ||
loadPriority: 101, // aligned with actionhero's redis initializer | ||
startPriority: 101, // aligned with actionhero's redis initializer | ||
stopPriority: 101, // aligned with actionhero's redis initializer | ||
initialize: function(api, next){ | ||
@@ -30,5 +34,5 @@ api.models = {}; | ||
}); | ||
function currySchemaFunc(SchemaExportFunc) { | ||
return function(a,b) { return SchemaExportFunc(a,b,api) } | ||
var currySchemaFunc = function(SchemaExportFunc) { | ||
return function(a,b) { return SchemaExportFunc(a,b,api); }; | ||
}; | ||
@@ -88,3 +92,3 @@ | ||
autoMigrate: function(next) { | ||
if(api.config.sequelize.autoMigrate == null || api.config.sequelize.autoMigrate) { | ||
if(api.config.sequelize.autoMigrate === null || api.config.sequelize.autoMigrate) { | ||
checkMetaOldSchema(api, umzug).then(function() { | ||
@@ -122,3 +126,2 @@ return umzug.up(); | ||
startPriority: 101, // aligned with actionhero's redis initializer | ||
start: function(api, next){ | ||
@@ -137,3 +140,3 @@ api.sequelize.connect(function(err){ | ||
function checkMetaOldSchema(api, umzug) { | ||
var checkMetaOldSchema = function(api, umzug) { | ||
// Check if we need to upgrade from the old sequelize migration format | ||
@@ -146,6 +149,6 @@ return api.sequelize.sequelize.query('SELECT * FROM "SequelizeMeta"', {raw: true}).then(function(raw) { | ||
}).catch(Sequelize.DatabaseError, function (err) { | ||
var noTableMsg = 'No SequelizeMeta table found - creating new table'; | ||
var noTableMsg = 'No SequelizeMeta table found - creating new table. (Make sure you have \'migrations\' folder in your projectRoot!)'; | ||
api.log(noTableMsg); | ||
console.log(noTableMsg); | ||
}); | ||
} | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "I use sequelize in actionhero as an ORM", | ||
"version": "0.8.0", | ||
"version": "0.8.5", | ||
"homepage": "http://actionherojs.com", | ||
@@ -8,0 +8,0 @@ "repository": { |
# ah-sequelize-plugin | ||
This plugin will use the sequelize orm to create `api.models` which contain your sequelize models | ||
This plugin will use the sequelize orm to create `api.models` which contain your sequelize models. | ||
@@ -8,3 +8,3 @@ ## Setup | ||
- install this plugin: `npm install ah-sequelize-plugin --save` | ||
- be sure to enable the plugin within actionhero (`config/plugins.js`) | ||
- be sure to enable the plugin within actionhero (`config/plugins.js`) or If you're using actionhero 13 or higher make sure you linked/included the plugin using `npm run actionhero link -- --name ah-sequelize-plugin` | ||
- you will need to add the sequelize package (`npm install sequelize --save`) to your package.json | ||
@@ -39,3 +39,3 @@ - you will need to add the sequelize-fixtures package (`npm install sequelize-fixtures --save`) to your package.json | ||
An example migration to create a `users` table would look like: | ||
```javascript | ||
```javascript | ||
// from ./migrations/20140101000001-create-users.js | ||
@@ -79,3 +79,3 @@ | ||
}, | ||
down: function(migration, DataTypes) { | ||
@@ -89,3 +89,3 @@ return Promise.all([ | ||
You can use the [sequelize-cli](http://docs.sequelizejs.com/en/latest/docs/migrations/) to create and execute migrations. | ||
You can use the [sequelize-cli](http://docs.sequelizejs.com/en/latest/docs/migrations/) to create and execute migrations. | ||
@@ -92,0 +92,0 @@ `api.sequelize.migrate` and `api.sequelize.migrateUndo` are now based on [Umzug](https://github.com/sequelize/umzug), and are maintained for legacy purposes. |
@@ -34,1 +34,6 @@ #!/usr/bin/env node | ||
}); | ||
console.warn('Warning:'); | ||
console.warn('For actionhero 13 or higher please make sure you link this plugin.'); | ||
console.warn('npm run actionhero link -- --name ah-sequelize-plugin'); | ||
console.warn('To read more about this, http://www.actionherojs.com/docs/#plugins'); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14320
217
0