question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adding new column to existing table

See original GitHub issue

hello, this is my class : public class UserInfoDb extends SugarRecord { public boolean isChecked ; public boolean isShowChanges ; public String Packages ;

public UserInfoDb(){

}

} now, i`m trying to add new string to this class like this :

public String TestField ;

i changed db version and create a sql file in asset/sugar_upgrades.

i tried this : alter table user_info_db add test_field TEXT;

also : alter table user_info_db add column test_field TEXT;

also i tried to create new table and copy old table to new table and drop old table too, after that all, seems sugar will do updates but when i`m trying to work with new column i will get this :

Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 4 columns

any idea?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Karuhangacommented, Nov 29, 2017

Hey, You need to add the new column/field to your class. Also, when you’re simply adding new columns, you’re not supposed to write update scripts. So you should delete that update file. Just add the field to the class and update the db version.

0reactions
Karuhangacommented, Nov 30, 2017

Ohhh awesome then. Good luck. And please close the issue if everything’s working great. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL ALTER TABLE Statement - W3Schools
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used...
Read more >
SQL Server ALTER TABLE ADD Column
First, specify the name of the table in which you want to add the new column. · Second, specify the name of the...
Read more >
Add Columns to a Table (Database Engine) - SQL Server
Insert columns into a table with Table Designer · In Object Explorer, right-click the table to which you want to add columns and...
Read more >
How to Add A New Column to a Table in SQL?
In SQL, create new column using the ALTER TABLE statement. This program helps to add column in SQL. You can also modify, or...
Read more >
SQL Server: ALTER TABLE ADD Columns in a Table
You can add columns to an existing table by using the ALTER TABLE statement. ... Use the ALTER TABLE ADD statement to add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found