Docs Menu
Docs Home
/ /
Atlas Device SDKs
/

Modify Schema in a Realm Studio

On this page

  • Overview
  • Add a Class to the Schema
  • Add a Property to the Class
  • Save Model Definitions
  • Perform a Migration

Realm Studio gives you tools to make non-breaking changes to your schema. You can:

Important

If you make changes to your schema in Realm Studio, you must migrate the realm file when you use it in your client app.

After you make schema changes, you can add values to the new properties and classes from within Realm Studio. You can also create new objects based on your new classes and properties. This gives you a graphical user interface (GUI) tool to experiment with changes to your schema until you get the object model you need.

When you've completed your changes, you can export your model definitions from Realm Studio. This gives you new class definitions in your language of choice, which you can drop into your code.

You can also save an updated version of the realm file to use in your app. When you save a realm file with an updated schema, you must perform a migration to use it in your app.

To add a new class to your schema:

  • Press the + button next to the Classes header in the upper-left hand corner of the Realm Studio window

  • Name your new class

  • Designate a primary key (Optional)

  • Press the Add class button

You'll now see a new class in the class list displayed in the left-hand sidebar.

To add properties to a class:

  • Select the class where you want to add properties in the left-hand sidebar

  • Press the + button under the Create {Class Name} button in the upper-right hand corner of the Realm Studio window

  • Name your new property

  • Select a type for your new property from the drop-down selector

  • Click the checkboxes to select Make this a list of strings and Optional: Allow a null value if needed

  • Press the Add property button

You'll see your new property displayed alongside the other class properties.

If you already have objects in your class, you can add values for this property by clicking into the property's field for each value. If this is a new class with no objects, you can create new objects in the class.

Tip

See also:

After you've made changes to your schema, you can export your new schema as class definitions.

To export updated class definitions:

  • Go to File > Save model definitions, and select your preferred language. Supported languages include: Swift, JavaScript, TypeScript, Java, Kotlin, and C#.

  • Specify a name and destination for your new class definitions. Press the Save button.

If your destination directory does not already exist, Realm Studio creates it. Inside, you'll find a file that contains a complete list of classes and properties, including new additions.

This is a great tool to iterate on your schema. You can also export class definitions in multiple languages for cross-platform development.

After you make changes to your schema, you can add values to new properties and even create new objects. If you want to then use this updated realm file in your app, you can save the data. Before you can use it in your client app, though, you'll need to perform a migration.

Realm requires you to increment the version monotonically when you change the schema. If you try to open a realm with an updated object schema without migrating, your client will throw an error.

For instructions on how to complete this migration, consult your SDK's migration guide.

← 
 →