{ "id": "103916", "key": "ALOY-345", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "14771", "description": "Alloy 0.3.5", "name": "Alloy 0.3.5", "archived": false, "released": true, "releaseDate": "2013-01-18" }, { "id": "14871", "description": "2013 Sprint 02", "name": "2013 Sprint 02", "archived": true, "released": true, "releaseDate": "2013-01-28" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-01-09T17:01:19.000+0000", "created": "2012-10-25T17:12:57.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "notable" ], "versions": [], "issuelinks": [ { "id": "24636", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "107114", "key": "ALOY-456", "fields": { "summary": "Support multiple databases in sql adapter", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } } ], "assignee": null, "updated": "2018-03-07T22:26:06.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "see conversation here: https://groups.google.com/forum/?fromgroups=#!topic/appc-ti-alloy/1q1e36mT6f0\r\n\r\nDevelopers should be able to preload sqlite databases with the sql adapter models. To do so, they can add the new \"db_file\" field with the location of their db file. In addition, you can also explicitly name the database with the \"db_name\" field. This allows developers to continue to access a named, pre-loaded database even if they remove the \"db_file\" field:\r\n\r\nh2. examples\r\n\r\n{code:javascript}\r\n// standard sql model using default _alloy_ db to create\r\n// table \"fighters\" based on config.columns\r\nexports.definition = {\r\n\tconfig: {\r\n\t\t\"columns\": {\r\n\t\t\t\"name\":\"text\",\r\n\t\t\t\"nickname\":\"text\"\r\n\t\t},\r\n\t\t\"adapter\": {\r\n\t\t\t\"type\": \"sql\",\r\n\t\t\t\"collection_name\": \"fighters\"\r\n\t\t}\r\n\t}\r\n}\r\n{code}\r\n\r\n{code:javascript}\r\n// sql model using specified customDb db to create\r\n// table \"fighters\" based on config.columns. customDb\r\n// can be referencing an existing db or creating a new one.\r\n// This allows for multiple sqlite dbs in an Alloy app.\r\nexports.definition = {\r\n\tconfig: {\r\n\t\t\"columns\": {\r\n\t\t\t\"name\":\"text\",\r\n\t\t\t\"nickname\":\"text\"\r\n\t\t},\r\n\t\t\"adapter\": {\r\n\t\t\t\"type\": \"sql\",\r\n\t\t\t\"collection_name\": \"fighters\",\r\n\t\t\t\"db_name\": \"customDb\"\r\n\t\t}\r\n\t}\r\n}\r\n{code}\r\n\r\n{code:javascript}\r\n// load myapp.sqlite db file if myapp db does not exist, auto-populate \r\n// config.columns based on `pragma table_info(\"fighters\")`, which lists \r\n// table info regarding the fighters table\r\nexports.definition = {\r\n\tconfig: {\r\n\t\t\"adapter\": {\r\n\t\t\t\"type\": \"sql\",\r\n\t\t\t\"db_file\": \"/sql_preload.sqlite\",\r\n\t\t\t\"collection_name\": \"fighters\"\r\n\t\t}\r\n\t}\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "Load pre-existing SQLite DBs with sql adapter", "creator": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "233749", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "pre-loaded databases supported as per the ticket description. An example can be found at: https://github.com/appcelerator/alloy/tree/master/test/apps/models/sql_preload", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-09T17:01:19.000+0000", "updated": "2013-01-09T17:01:19.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }