[ALOY-1195] Alloy Migrations: Template up.down functions do not match documentation
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2014-12-16T12:44:56.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.7.0 |
Components | Samples & Templates, Tooling |
Labels | n/a |
Reporter | Tim Statler |
Assignee | Tim Poulsen |
Created | 2014-12-02T19:46:55.000+0000 |
Updated | 2014-12-16T12:44:56.000+0000 |
Description
When generating a migration with the Alloy CLI (1.5.1), the generated file has this code:
{noformat}
migration.up = function(db) {
};
migration.down = function(db) {
};
{noformat}
But documentation uses 'migrator' in place of 'db' for the function parameter.
Since the passed-in object itself has a 'db' parameter, the 'migrator' naming helps to avoid potential confusion.
migrator.db.execute(...)
vs.
db.db.execute(...)
It's easy to change the docs to match the generated code, but the report says *"the 'migrator' naming helps to avoid potential confusion"*. So, maybe we should consider changing the CLI output to match the docs, rather than the other way around. [~axmo] [~sliang], [~skypanther]?
I agree, this would make more sense as an update to Alloy. It would be an easy change to make in Alloy, too. Can you convert this to an Alloy ticket?
Moved, thanks Tim. Still assigned to Ben, however.
Yes, a change to the Alloy migration template was what I had in mind when creating the ticket.
Thanks Alex. We already have an Alloy version in the testing queue. This change will have to be in the next release. But it's a simple change so it shouldn't be a problem.
PR: https://github.com/appcelerator/alloy/pull/635 Functional test: 1. Create a new Alloy project 2. In the project's directory, enter
alloy generate model foo sql name:text age:integer
to create a model. 3. Enteralloy generate migration foo
4. Open the migration file; it will contain empty functions in a form like documented in [the migrations guide](http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Sync_Adapters_and_Migrations-section-36739597_AlloySyncAdaptersandMigrations-Migrations) with arguments namedmigrator
not db.PR merged.