A reader asked how this works during iterative development: you are building an app, add a query, and recompile. Does the data survive, and is the process fast?
Adding a query
Suppose your app already stores customers. Add a function inside the owner of the Customer model to list those customers by ID:
fn all_customers() {
[for customer in Customer
order_by customer.id
select customer]
}This adds a read over the existing model. When the updated application opens the existing database, the customers are still there.
Declaring queries at build time does not mean declaring every query you will ever need on day one. You can add and change them as the application develops.
Compilation and storage changes are separate work
A query change that keeps the same stored schema can use the existing data. It does not inherently require a data migration or a full rewrite of the database.
You declare the queries your application needs. MelodyDB derives the indexes that support them; you do not create or manage indexes yourself. If a new query leads the compiler to choose a new index, MelodyDB must populate it from existing rows as part of the update. That work can depend on how much data there is, separately from the time needed to compile the code.
For example, adding a query over existing customer fields differs from changing what a stored field means. Recompilation alone cannot decide how old values should be transformed when the application’s meaning changes.
Compare the query above with adding this field inside Customer:
active: bool = trueThe query reads existing rows. The new field changes their stored shape and supplies an initial value. Lock records that evolution so the update can apply it to existing data.
Edit the model in Score
Score is designed to make this an ordinary part of development. You edit the model as you want it to look now, with the information needed to connect it to its previous shape.
For example, suppose a customer model already has a name field. To rename it and add an active flag:
model Customer {
id: u64 key
display_name: text(max: 120B) was name
active: bool = true
}was name tells the compiler that display_name is the same field under a new name. It preserves the field’s identity and existing values. The compiler does not have to guess whether you meant a rename or a deletion followed by an addition.
The default initializes active to true for existing rows and supplies the value for later insertions that omit it. For a type change that needs a conversion, Score also supports was OldType using conversion: you supply the meaning of the conversion, and the compiler checks it.
Record the change with melody lock
After editing the source, run melody lock. It checks the proposed evolution against the recorded predecessor and writes the package lock and generated history, including the ordered evolution steps and the compiler inputs they need.
The intended CLI experience is simple:
melody lockKeep score-package.lock and score-history/ in version control alongside the Score source. They preserve the information needed to interpret earlier versions of the stored data, even as the current model changes.
The compiled binary retains the entire migration history, including the earlier schema versions and their conversions. That lets it read data written by older versions of the application and interpret it through the current model. Editing the model does not erase the knowledge of what came before.
For changes like this rename and defaulted field addition, you describe the change in the model; the tooling records the evolution steps. You do not need to maintain a separate handwritten migration script for each one.
Lock records and checks the change; it does not migrate a running database. The built application carries the recorded evolution needed when the update is applied. Deleting a field requires explicit authorization, so removing a line from the model alone does not authorize throwing away its data.
The development loop is: edit Score, lock the change, then build and run the updated application against the existing data. More substantial changes still need an explicit conversion or migration; the language makes that intent part of the application source.
Build and release the updated application
With the change recorded, build and release the updated application:
melody build
melody releaseBuild compiles the application. Release applies the new version and its recorded migrations to the existing database. Your data carries forward.
After the next source edit, repeat the same sequence:
melody lock
melody build
melody releaseRelease handles the operational work
In existing systems, writing the migration is often only the beginning. Teams must also work out how long the application will be unavailable, how copying data or building indexes will affect live traffic, and how to roll back if the new version fails.
MelodyDB’s design puts those responsibilities in melody release. You describe your intent: where the application should run, how much downtime is acceptable, the performance and resource limits it must stay within, and the recovery requirements. Release handles the migration and rollout within those constraints.
The intended experience is that once you type melody release, your work is done. The rollout may still take time, but MelodyDB owns getting it through to completion within your declared requirements. You should not have to watch progress, coordinate the steps, or intervene to keep it moving. A rollout failure that leaves the developer babysitting the process is a bug in MelodyDB, not an expected part of deploying an application.
For example, the requirements might look like this in plain language:
Target: the production environment
Downtime: a brief planned pause is acceptable
Performance: stay within the app’s latency budget
Rollback: preserve all acknowledged writesThose requirements guide how Release prepares the update, schedules data migration and index construction, switches to the new version, checks its health, and manages rollback. You describe the acceptable outcome; you do not write a separate deployment procedure for each schema change.
Rollback includes the data, not just the executable. Release must check that a return path can preserve committed data and completed work. If an update cannot meet the declared downtime, performance, or recovery requirements, it must surface that conflict before proceeding rather than silently relax them.
Is it fast?
Release time depends on the change, the amount of data, and your requirements. Allowing a brief pause may permit a different rollout from requiring continuous availability. Limits on the performance impact of migration work can also affect how long it takes. Those tradeoffs belong in your declared intent; managing the resulting rollout belongs to MelodyDB.
The useful measurements will separate compilation, opening the updated application with existing data, and any work MelodyDB derives from your changes, such as populating an index or applying a migration. A query edit that reuses existing storage can have a different update cost from one that requires processing a large dataset.
The stages can be timed separately:
time melody lock
time melody build
time melody releaseThe release measurement includes its checks and startup work, so it is not a pure migration measurement. Compare like-for-like runs and record whether the update changed the stored schema.