如何将新列添加到SQL数据库?

问题描述 投票:0回答:1

我是移动开发/ Azure的新手。

我正在按照本教程(https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-ios-get-started)设置一个Azure后端,该后端与简单的SQL数据库连接到iOS应用程序(用Swift编写)。

我启用了离线同步(已经预先编写了https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-ios-get-started-offline-data代码)。但是,我试图将数字类型的另一个列/变量添加到SQL数据库。我正在做的步骤是:

  1. 在Azure Easy Tables中,我选择了数据库并添加了另一列。
  2. 在我的代码中,我更改了有效负载
     let itemToInsert = ["text": text, "complete": false, "__createdAt": Date()] as [String : Any]

        UIApplication.shared.isNetworkActivityIndicatorVisible = true
        self.table!.insert(itemToInsert) {
            (item, error) in
            UIApplication.shared.isNetworkActivityIndicatorVisible = false
            if error != nil {
                print("Error: " + (error! as NSError).description)
            }
        }

       let itemToInsert = ["text": text, "complete": false, "__createdAt": Date(),"new_column":29] as [String : Any]

        UIApplication.shared.isNetworkActivityIndicatorVisible = true
        self.table!.insert(itemToInsert) {
            (item, error) in
            UIApplication.shared.isNetworkActivityIndicatorVisible = false
            if error != nil {
                print("Error: " + (error! as NSError).description)
            }
        }

新代码运行,但new_column的值未显示在Azure Web门户的Easy Tables视图中。有人有什么建议吗?

我已经阅读了以下相关问题:

  1. How to Add Columns to Easy Table for Azure Demo iOS App (Todo List)

它建议清理XCode构建。我试过了,它没有改变任何东西。

  1. Swift Azure Mobile QuickStart - Add and sync PNG image

没有提供答案。

任何帮助将不胜感激 - 非常感谢!

azure azure-sql-database azure-mobile-services
1个回答
0
投票

如果我错了,请纠正我,但是在部署初始结构后,您正试图更改表结构。我没有任何Swift经验,因此不知道这些库中有哪些API可用。话虽如此,我会删除初始结构并让应用程序重建它。如果删除表不是一个选项,我会通过门户手动添加列。

© www.soinside.com 2019 - 2024. All rights reserved.