{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3142","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3142/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3142/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3142/events","html_url":"https://github.com/Starcounter/Starcounter/issues/3142","id":120236282,"number":3142,"title":"pnext: Implement schema upgrade","user":{"login":"k-rus","id":1726044,"avatar_url":"https://avatars.githubusercontent.com/u/1726044?v=3","gravatar_id":"","url":"https://api.github.com/users/k-rus","html_url":"https://github.com/k-rus","followers_url":"https://api.github.com/users/k-rus/followers","following_url":"https://api.github.com/users/k-rus/following{/other_user}","gists_url":"https://api.github.com/users/k-rus/gists{/gist_id}","starred_url":"https://api.github.com/users/k-rus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k-rus/subscriptions","organizations_url":"https://api.github.com/users/k-rus/orgs","repos_url":"https://api.github.com/users/k-rus/repos","events_url":"https://api.github.com/users/k-rus/events{/privacy}","received_events_url":"https://api.github.com/users/k-rus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/BAH","name":"BAH","color":"e102d8"}],"state":"open","locked":false,"assignee":{"login":"chrhol","id":1658979,"avatar_url":"https://avatars.githubusercontent.com/u/1658979?v=3","gravatar_id":"","url":"https://api.github.com/users/chrhol","html_url":"https://github.com/chrhol","followers_url":"https://api.github.com/users/chrhol/followers","following_url":"https://api.github.com/users/chrhol/following{/other_user}","gists_url":"https://api.github.com/users/chrhol/gists{/gist_id}","starred_url":"https://api.github.com/users/chrhol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrhol/subscriptions","organizations_url":"https://api.github.com/users/chrhol/orgs","repos_url":"https://api.github.com/users/chrhol/repos","events_url":"https://api.github.com/users/chrhol/events{/privacy}","received_events_url":"https://api.github.com/users/chrhol/received_events","type":"User","site_admin":false},"milestone":null,"comments":30,"created_at":"2015-12-03T18:19:45Z","updated_at":"2015-12-08T09:51:04Z","closed_at":null,"body":"Now metalayer provides an API function to alter table and add columns. What it does it creates layout and updates metadata. The function returns metalayaer handle. So the schema updates, need to decide about the upgrade, call the metalayer function with columns to add, retrieve layout handle and update .net metadata such as type binding into new layout handle. In Level1 the method is in `Starcounter.SqlProcessor.SqlProcessor` and is:\r\n```c#\r\ninternal static unsafe extern uint star_alter_table_add_columns(ulong context_handle,\r\n            string full_table_name, STAR_COLUMN_DEFINITION_HIGH* added_columns,\r\n            out ulong new_layout_handle);\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/162834165","html_url":"https://github.com/Starcounter/Starcounter/issues/3142#issuecomment-162834165","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3142","id":162834165,"user":{"login":"eriohl","id":3438751,"avatar_url":"https://avatars.githubusercontent.com/u/3438751?v=3","gravatar_id":"","url":"https://api.github.com/users/eriohl","html_url":"https://github.com/eriohl","followers_url":"https://api.github.com/users/eriohl/followers","following_url":"https://api.github.com/users/eriohl/following{/other_user}","gists_url":"https://api.github.com/users/eriohl/gists{/gist_id}","starred_url":"https://api.github.com/users/eriohl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriohl/subscriptions","organizations_url":"https://api.github.com/users/eriohl/orgs","repos_url":"https://api.github.com/users/eriohl/repos","events_url":"https://api.github.com/users/eriohl/events{/privacy}","received_events_url":"https://api.github.com/users/eriohl/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T09:51:04Z","updated_at":"2015-12-08T09:51:04Z","body":"> Db.LookupTable currently only retrieve one layout and creates a TableDef from that one. If there are more then one layout, is there some way to determine which one is the latest (in the result from sccoredb.stari_context_get_layout_infos_by_token)? I made the assumption now that the last one is the last one created.\r\n\r\nThis incorrect. There is no guaranteed order between them. You need to get this from meta-data.\r\n\r\nRemember that you need to register a type binding for each layout for the type so that type binding can be looked up on layout handle. Also, you need to change the expected layout in the record reference on record fetch (iterator_next, filter_iterator_next and lookup)."}}