Giter Club home page Giter Club logo

Comments (8)

satyan avatar satyan commented on July 21, 2024

We've added support for that recently. This feature is still in beta stage.

Here's how you'd do it.

  1. Create a folder named "sugar_upgrades" in your assets folder.
  2. Create a file named <db_version>.sql in that folder. eg. 1.sql, 2.sql
  3. This file would contain all the update/alter queries for that particular version.
  4. Change the version field in AndroidManifest.xml
<meta-data android:name="VERSION" android:value="2" />
  1. This would execute all the .sql files that have changed from your current version.

from sugar.

tobykurien avatar tobykurien commented on July 21, 2024

That sounds great! Like Rails migrations. I like it.

from sugar.

tsuharesu avatar tsuharesu commented on July 21, 2024

What if I already have a DB? What Sugar will do the first time the app open (after the upgrade)?

Will it have some Exceptions because the tables already exists, will it drop all the tables?

And if I have scripts, will it just use the scripts or will it try to create the tables?

Just some questions =P

from sugar.

satyan avatar satyan commented on July 21, 2024

@tsuharesu An upgrade right now just executes the migration scripts.
http://satyan.github.io/sugar/migration.html

from sugar.

tsuharesu avatar tsuharesu commented on July 21, 2024

Hmm, understood. If I have the scripts, they will be executed. If not, dropTable > createTable.
https://github.com/satyan/sugar/blob/master/library/src/com/orm/SugarDb.java#L137

Thanks 👍

from sugar.

rastoarpit avatar rastoarpit commented on July 21, 2024

After upgrading my sugar[using 1.3] record, with alter table query i am adding a column to existing table.
Column is there but when i add a value and save it then it does not work rather it takes a null/default value even after the upgrade. While everything works great on fresh install where table gets created with this column already.

from sugar.

refaelsh avatar refaelsh commented on July 21, 2024

I have exactly the same problem as rastoarpit.

from sugar.

8manuel avatar 8manuel commented on July 21, 2024

I have the same problem as @rastoarpit and @refaelsh
Even in the log it appears the alter table
I/Sugar: ALTER TABLE ROSCA ADD COLUMN PHOTO TEXT
However debugging the new column not appears

from sugar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.