How can i add new table in existing realm database?

Rajesh Gauswami :

I am using realm 5.0.0 I want to add new table in existing data base how can i do that?

I have tried to find out solution but I found how to edit table but don't found how can i add new Table in realm in migration.

Realm.init(this);
        RealmConfiguration config = new RealmConfiguration.Builder()
                .name("myrealm.realm")
                .schemaVersion(2)
                .migration(new RealmMigration() {
                    @Override
                    public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
                        if (oldVersion == 0) {
                            RealmObjectSchema personSchema = realm.getSchema().get("SKUItem");
                            personSchema
                                    .removeField("created_date")
                                    .removeField("modification_date")
                                    .addField("created_date", String.class)
                                    .addField("modification_date", String.class)
                            ;
                        } if (oldVersion == 1) {
                            // Here I want to add new Table 
                        }
                    }
                })
                .build();
        Realm.setDefaultConfiguration(config);
Carlos :

It would be something like this:

// Create a new class
schema.create("NewTable")
    .addField("id", int.class, FieldAttribute.PRIMARY_KEY)
    .addField("name", String.class, FieldAttribute.INDEXED);
olderVersion++;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how can I create new XML file from existing database in PostgreSQL database using java

Add new table to an existing database using database first approach EF

How to add existing objects on a new class on Realm Migration in Android

How can I add a new folder to existing project on a branch, containing only new folder?

Can I add a new constructor to an existing class?

How can I add/destroy new objects to existing formation?

RealmMigrationNeededException: Migration is required Realm, while adding new table on existing database, Android

How can I add new row to database with values stored in ObservableCollection?

How can I add an auto generated ID to an existing table?

How can I add new values to the beginning of an existing array?

how can i add new row my react bootstrap table

How can I implement the ability to add a new task to an existing list (project) or to a new one

How can I check existing columns in a table with the new value before add the new record into the access table?

How can I add an order table to my SQL database?

How can I add properly the version or a table database in WordPress?

How can I add a new object to an existing Entity, PUT the data and have EF add it to my database?

What should I do add new table to existing database or make new database?

How do I add rows from a table of a MySQL database A to an existing table in database B

How can I add new directive information from a database?

How can I add a new attribute from another table to a serializer?

How can I insert an array to database table with new rows

How can I let the user add an attachment to my app like a pdf or jpg and then how can I store it in my Realm Database?

How can I add to an existing value in sql table

How can I add new key values to existing ones in JavaScript?

Add new column to existing database table

How can I update a existing Keycloak client attribute in a realm?

How can I add a new plots to existing figures?

How can I add new rows and columns to the table with Django?

How can i add new key and value in a existing list