Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview
On this page

preflight: nothing was deployed

A deploy stopped because a schema change cannot apply to the data your lunas already hold.

Every deploy compares your new code with the version already running. A change that existing lunas cannot take stops the whole deploy, and nothing changes.

Issue

luna deploy lists the changes, marks one or more as blocked:, and stops. Adding a required done column to the items table of List prints this. luna dev prints the same lines, then waits for your next save.

Preflight for <ORG>/<PROJECT> (dev):
  List: add column items.done (bool)
  blocked: List: new required column items.done needs a default, or an onMigrate that fills it in
error: preflight: nothing was deployed

Cause

Each blocked: line is a change that existing rows or lunas cannot take on their own:

Blocked change Why
A new required column with no default Existing rows have no value for it
An optional column made required, with no default Existing empty values would break the rule
A column that changes type Existing values need converting
A table whose primary key changes The table has to be rebuilt
Key fields that change The key is each luna’s identity
A stream that changes between live and not Its offsets would go out of order

The first four pass once the luna type has an onMigrate hook. Luna then tries the hook on a sample of existing lunas first. A dry run line with failures also stops the deploy, and shows each failing key and its error.

Solution

Fix the change the blocked: line names, then deploy again. A required column takes a default.

import { defineLuna, t, table } from "luna";

export const List = defineLuna({
  name: "List",
  visibility: "public",
  key: { id: t.string() },
  schema: {
    items: table({ id: t.id(), text: t.string(), done: t.bool().default(false) }),
  },
  handlers: (h) => ({
    add: h({ args: { text: t.string() } }, (ctx, { text }) => {
      ctx.db.items.insert({ text });
    }),
    all: h({ query: true }, (ctx) => ctx.db.items.find({ orderBy: "id" })),
  }),
});

A type change or a new primary key needs an onMigrate hook that moves the data, as Change a schema shows. Key fields and a stream’s live setting cannot change at all, so make a new luna type or stream and move the data across. Run luna deploy --preflight to check without deploying.

Was this page helpful?