Search code examples
rhomobile

RhoMobile: How to add new coloumn in the table?


I am using fixed schema for creating table in the database. below is my employee.rb file.

    class Employee
        include Rhom::FixedSchema
        set :schema_version, '1.1'
        property :name, :string
        property :address , :string
        property :company , :string
        property :salary , :string
        property :salary1 , :string
        property :age , :string
        property :gender , :string
      # Uncomment the following line to enable sync with Employee.
      # enable :sync

      #add model specific code here
    end

whenver i try to add a new column named "name123" in the table, i am getting below error.

Error: could not prepare statement: 1; Message: table Employee has no column named name123

Thanks,


Solution

  • When you use FixedSchema you need to manually add columns with "ALTER TABLE" SQL statements. That definition on the class is used only for creating the table. The altering process is by your care.

    More details you could find in this documentation page:
    http://docs.rhomobile.com/en/4.1.0/guide/rhom_ruby#data-migrations