{ "id": "117134", "key": "AC-2503", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2013-07-23T22:02:25.000+0000", "created": "2013-07-12T11:51:39.000+0000", "labels": [ "Backbone", "Models", "adapter", "migration" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41:33.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14544", "name": "Alloy", "description": "Please enter tickets related to the Alloy here." }, { "id": "14552", "name": "Appcelerator CLI", "description": "Please enter tickets related to Tooling and the CLI here" } ], "description": "Hi Tony,\r\n\r\nI have two bugs regarding migration in Alloy.\r\n\r\n*Bug/unexpected result 1:*\r\n\r\nWhen doing a migration with the *sql* adapter, the script fails when executing migrations on first run on a fresh installed app. This is because the migration script will go through each migration, without creating the table beforehand. Hence, the first migration MUST include the definition of the table. e.g. \r\n\r\n{code:javascript}\r\nmigration.up = function(migrator) {\r\n\tmigrator.createTable({\r\n\t\t\"columns\": {\r\n\t\t \"id\": \"INTEGER\",\r\n\t\t \"title\": \"TEXT\",\r\n\t\t \"icon\": \"TEXT\",\r\n\t\t \"type\": \"TEXT\",\r\n\t\t \"parent_id\": \"INTEGER\"\r\n\t\t}\r\n\t});\r\n\t\r\n\tmigrator.db.execute('ALTER TABLE ' + migrator.table + ' ADD COLUMN sort INT;');\r\n};\r\n{code}\r\n\r\nBut this is not logical. In my opinion the best approach would be to have the adapter create the table if it does not exists and afterwards go through all the migrations. In this manner, the above migration should only be:\r\n\r\n{code:javascript}\r\nmigration.up = function(migrator) {\r\n\tmigrator.db.execute('ALTER TABLE ' + migrator.table + ' ADD COLUMN sort INT;');\r\n};\r\n{code}\r\n\r\nMake sense? \r\n\r\n\r\n*Bug 2:*\r\nThis might be a tooling issue, but here we go.\r\nWhen I want to create a new migration for a model, its not possible because it already have a migration. This is wrong, because the migrations are controlled by timestamps, so its the idea to have the same name. Please look at the attachment migration.png. \r\n", "attachment": [ { "id": "40708", "filename": "migration.png", "author": { "name": "viezel", "key": "viezel", "displayName": "Mads Moller", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-07-12T11:51:39.000+0000", "size": 25994, "mimeType": "image/png" } ], "flagged": false, "summary": "Alloy: Migrations bugs", "creator": { "name": "viezel", "key": "viezel", "displayName": "Mads Moller", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "viezel", "key": "viezel", "displayName": "Mads Moller", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 3.1.0.GA \r\nAlloy 1.1.3", "comment": { "comments": [ { "id": "261629", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "1. I don't know, I think I prefer the usage of migrations to be explicit. If you don't use migrations, the table will be created automatically. If you do use migrations, the assumption is that you should handle things manually as you may need to do something before you even create the table. I don't think that's one I'm going to change, but if you have a more compelling argument I'm all ears.\r\n\r\n2. This would be a TISTUD issue, as this is definitely not a limitation imposed by Alloy. I will bring [~mxia] into the conversation so that he can get it addressed in Studio.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-12T15:30:41.000+0000", "updated": "2013-07-12T15:31:09.000+0000" }, { "id": "261643", "author": { "name": "mxia", "key": "mxia", "displayName": "Michael Xia", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The No. 2 is covered in TISTUD-2300 and fixed for the upcoming 3.1.2 release. If you would like to update to it now, you could use the update site http://preview.appcelerator.com/appcelerator/studio/standalone/update/beta/.\n", "updateAuthor": { "name": "mxia", "key": "mxia", "displayName": "Michael Xia", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-12T16:43:35.000+0000", "updated": "2013-07-12T16:43:35.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }