Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1195] Alloy Migrations: Template up.down functions do not match documentation

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusResolved
ResolutionFixed
Resolution Date2014-12-16T12:44:56.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.7.0
ComponentsSamples & Templates, Tooling
Labelsn/a
ReporterTim Statler
AssigneeTim Poulsen
Created2014-12-02T19:46:55.000+0000
Updated2014-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(...)

Comments

  1. Tim Statler 2014-12-03

    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]?
  2. Tim Poulsen 2014-12-03

    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?
  3. Tim Statler 2014-12-03

    Moved, thanks Tim. Still assigned to Ben, however.
  4. Alex Montgomery 2014-12-03

    Yes, a change to the Alloy migration template was what I had in mind when creating the ticket.
  5. Tim Poulsen 2014-12-03

    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.
  6. Tim Poulsen 2014-12-15

    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. Enter alloy 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 named migrator not db.
  7. Feon Sua Xin Miao 2014-12-16

    PR merged.

JSON Source