> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrading from an Alpha

> Database changes made to the v2 baseline migrations during the 2.0 alpha, and how to bring an alpha install up to date.

This page lists every change made to the v2 baseline migrations from the 2.0 alpha releases up to 2.0.0-beta.1, so an application installed on an alpha can catch up with the current schema.

## Why alpha installs need this

Lunar v2 ships a flat baseline: one migration per table, dated `2026_01_01_*`. While v2 was in alpha, schema changes were folded into those baseline migrations instead of being added as new migrations. An application that already ran a baseline migration does not run it again, so it never receives the columns that were added to that migration later.

Alpha releases were not intended for production use. If an application was built on one anyway, it needs a migration of its own to add the missing columns. From 2.0.0-beta.1 onward, the baseline migrations no longer change: every schema change ships as a new migration that `php artisan migrate` runs, so this page no longer grows.

> [!NOTE]
>
> New migration files are not a problem. `php artisan migrate` runs any Lunar migration that is not yet recorded in the `migrations` table, such as `create_refund_lines_table`. Only changes made to a migration the application has already run need the steps on this page.

## Upgrading

1. Find the alpha the application was installed on. Check `composer.lock` for the `lunarphp/core` version that was first installed, or look at the batch that recorded the `2026_01_01_000000_create_assets_table` row in the `migrations` table and compare its date with the release dates below.
2. Create a migration in the application that adds every change listed under that release and each later one. Guard each change with `Schema::hasColumn()` or `Schema::hasTable()`, so the migration is safe to run on any alpha and on a fresh install.
3. Give the migration a name that sorts before `2026_01_01_000071`, for example `2026_01_01_000070_catch_up_lunar_alpha_schema.php`. Lunar's `2026_01_01_000071_add_product_types_default_tax_class_foreign_key` migration needs `product_types.default_tax_class_id` to exist, and Laravel runs migrations from every path in filename order.
4. Run `php artisan migrate`.

The `lunarphp/upgrade` package already adds most of these columns to v1 databases, with guards and backfills. Its data migrations in `packages/upgrade/database/migrations` are a useful reference, but do not run them against an alpha database: they are written for a v1 schema. The reference column in each table below names the relevant file.

### Using an AI assistant

The tables on this page are written so an AI coding assistant can generate the catch-up migration. A prompt such as the following works well:

```text theme={null}
My application was installed on Lunar 2.0.0-alpha.N. Read
https://docs.lunarphp.com/2.x/getting-started/overview/alpha-upgrade-guide and
write one migration that applies every change listed for alpha.N+1 and later.
Guard each column with Schema::hasColumn() and each table with
Schema::hasTable(). Prefix table names with config('lunar.database.table_prefix').
Backfill unique, non-nullable columns before adding the unique index. Name the
file 2026_01_01_000070_catch_up_lunar_alpha_schema.php.
```

Review the generated migration and run it against a copy of the production database first.

## Changes by release

Each section lists the changes that first appeared in that release. Apply the section for every release after the one the application was installed on. All table names below omit the configured table prefix (`lunar_` by default).

### 2.0.0-alpha.1 to alpha.4

Released July 1 to July 8, 2026. These releases made no changes to existing migrations.

### 2.0.0-alpha.5

Released August 29, 2026.

| Table | Change | Reference |
| - | - | - |
| `brands` | Add `handle` `string`, unique. Add `status` `string`, default `active`, indexed. | `2026_06_01_000009_add_brand_handle_and_status` |
| `customers` | Add `admin_notes` `text` `nullable`. | |
| `product_options` | Add `type` `string`, default `text`, indexed. | |
| `product_types` | Add `handle` `string`, unique. Add `status` `string`, default `active`, indexed. Add `description` `text` `nullable`. Add `default_tax_class_id` `foreignId` `nullable`, without a constraint (`2026_01_01_000071` adds it). Add `attribute_data` `jsonb` `nullable`. | `2026_06_01_000011_add_product_type_columns` |
| `attributes` | Add `validation_rules` `json` `nullable`. | `2026_06_01_000003_convert_attribute_data_keys_to_ids` |
| `collections` | Add `handle` `string`, unique. | `2026_06_01_000010_add_collection_handle` |
| `order_lines` | Add `refunded_quantity` `unsignedInteger`, default `0`. | `2026_06_01_000019_add_order_line_refunded_quantity` |
| `product_associations` | Add `sort` `unsignedInteger`, default `0`. | `2026_06_01_000016_add_product_association_sort` |
| `product_variants` | Add `enabled` `boolean`, default `true`, indexed. | `2026_06_01_000012_add_product_variant_enabled` |
| `staff` | Add `preferred_locale` `string` `nullable`. | `2026_06_01_000021_add_staff_preferred_locale` |

`brands.handle`, `collections.handle` and `product_types.handle` are unique and not nullable. Add each as nullable, fill it with a unique value for every existing row (for example a slug of the name, with a numeric suffix for duplicates), then make it non-nullable and add the unique index.

New migrations in this release (run by `php artisan migrate`): `2026_01_01_000071_add_product_types_default_tax_class_foreign_key`, `2026_01_01_000072_create_refund_lines_table`, `2026_07_09_000000_create_staff_password_reset_tokens_table`, the panel's `create_edit_drafts_table` and `create_staff_preferences_table`, and PayPal's `create_paypal_orders_table`.

> [!NOTE]
>
> `staff.preferred_locale` was originally added by a separate `2026_07_16_000000_add_preferred_locale_to_staff_table` migration, which has since been folded into `create_staff_table`. An application installed on alpha.5 or later already has the column.

### 2.0.0-alpha.6

Released September 1, 2026. This release made no changes to existing migrations.

### 2.0.0-alpha.7

Released November 6, 2026.

| Table | Change | Reference |
| - | - | - |
| `addresses` | Add `last_used_at` `timestamp` `nullable`. | |
| `orders` | Add `internal_notes` `text` `nullable`. | `2026_06_01_000017_add_order_internal_notes` |
| `carts` | Add `remember_token` `string(64)` `nullable`, unique. | `2026_06_01_000018_add_cart_remember_token` |
| `order_lines` | Add `parent_line_id` `foreignId` `nullable`, indexed, constrained to `order_lines`, cascade on delete. | |
| `stripe_payment_intents` | Add `flavour` `string`, default `standard`. | |

New migrations in this release: the bundles package's `create_bundles_table`, `create_bundle_groups_table` and `create_bundle_components_table`.

### 2.0.0-alpha.8

Released November 10, 2026.

| Table | Change | Reference |
| - | - | - |
| `carts` | Add the totals snapshot, all `nullable`: `sub_total`, `sub_total_discounted`, `discount_total`, `shipping_sub_total`, `shipping_tax_total`, `shipping_total`, `tax_total` and `total` as `unsignedBigInteger`; `tax_breakdown`, `shipping_breakdown`, `shipping_tax_breakdown`, `discount_breakdown` and `free_items` as `jsonb`; `calculated_revision` `unsignedInteger`; `calculated_at` `timestamp`. Add `revision` `unsignedInteger`, default `0`. | `2026_06_01_000017_add_cart_totals_columns` |
| `cart_lines` | Add the totals snapshot, all `nullable`: `unit_price`, `unit_price_incl_tax`, `sub_total`, `sub_total_discounted`, `discount_total`, `tax_total` and `total` as `unsignedBigInteger`; `tax_breakdown` `jsonb`; `promotion_description` `string`. | `2026_06_01_000017_add_cart_totals_columns` |

A `NULL` totals column means the cart has not been calculated yet, so existing carts need no backfill.

### 2.0.0-alpha.9

Released November 11, 2026. This release made no changes to existing tables. It changed `2026_01_03_000013_add_can_manage_shipping_permission` to resolve the auth guard through core, which only matters for an application that has not run it yet.

### 2.0.0-beta.1

Released December 1, 2026. This is the last release that changed existing migrations.

| Table | Change | Reference |
| - | - | - |
| `carts` | Add `payment_terms` `string` `nullable`. | `2026_06_01_000022_add_payment_terms` |
| `orders` | Add `payment_terms` `string`, default `checkout`. | `2026_06_01_000022_add_payment_terms` |
| `edit_drafts` | Add `version` `unsignedInteger`, default `0`. | |
| `attributes` | Add `description` `string` `nullable`. | `2026_06_01_000023_add_attribute_description` |
| `product_option_values` | Add `colour` `string(7)` `nullable`. | `2026_06_01_000024_add_product_option_value_colour` |
| `cart_lines` | Add `added_by_discount_id` `foreignId` `nullable`, constrained to `discounts`, null on delete. | `2026_06_01_000025_add_line_added_by_discount` |
| `order_lines` | Add `added_by_discount_id` `foreignId` `nullable`, constrained to `discounts`, null on delete. | `2026_06_01_000025_add_line_added_by_discount` |
| `cart_line_discount` | Drop the table if it is empty. Lunar never used it. | `2026_06_01_000025_add_line_added_by_discount` |
| `locations` | Add `line_one`, `line_two`, `line_three`, `city`, `state`, `postcode` and `contact_phone` as `string` `nullable`. Add `country_id` `foreignId` `nullable`, constrained to `countries`, null on delete. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `carts` | Add `fulfilment_method` `string` `nullable`, indexed. Add `pickup_location_id` `foreignId` `nullable`, indexed, constrained to `locations`, null on delete. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `cart_lines` | Add `fulfilment_method` `string` `nullable`, indexed. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `orders` | Add `pickup_location_id` `foreignId` `nullable`, indexed, constrained to `locations`, null on delete. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `order_lines` | Add `fulfilment_method` `string` `nullable`, indexed. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `product_variants` | Add `fulfilment_methods` `jsonb` `nullable`. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `shipping_methods` | Table-rate shipping only. Add `pickup_location_id` `foreignId` `nullable`, constrained to `locations`, null on delete. | `2026_06_01_000032_add_fulfilment_choice_columns` |
| `locations` | Add `accepts_pickup` `boolean`, default `false`, indexed. | `2026_06_01_000033_add_location_accepts_pickup` |
| `product_variants` | Add `continue_selling` `boolean`, default `true`, indexed. Add `sell_against_incoming` `boolean`, default `false`. Backfill both from `selling_policy` (see below), then drop `selling_policy` and `backorder` with their indexes. | |

`edit_drafts.version` counts writes to a staff member's draft, so the panel can refuse a save from a browser tab holding an older copy. Existing drafts need no backfill: each one starts at version `0`, and the edit page passes the stored version to the panel.

`product_option_values.colour` holds the `#RRGGBB` colour of a value of a colour option, which alpha releases kept in `meta['colour']`. Lunar no longer reads the `meta` key, so copy it into the column, in upper case, for every value whose `meta` has one.

`added_by_discount_id` marks the cart lines a Buy X Get Y discount added automatically, which alpha releases recorded in `meta['added_by_discount']`. A line left unmarked behaves as a line the shopper added. To keep reward lines already in carts and orders marked, set `added_by_discount_id` to the discount ID used as the key in `meta['added_by_discount']`, then remove that key.

Lines with `added_by_discount_id` set now follow the reward their discount earns: each calculation lowers, raises or deletes them, and deleting the discount deletes them from carts without a completed order. They no longer count toward any discount's conditions or minimum spend, and `Cart::updateLine()` refuses to change their quantity. No schema change is needed.

A null `fulfilment_method` or `pickup_location_id` means the choice is inferred as before, so carts, lines and variants need no backfill. Alpha releases recorded a pickup order with `meta['pickup']` (`meta['collect']` before alpha.8) on its shipping line, which Lunar no longer reads. `Order::isPickup()` now reads the order's fulfilments, so orders that already have fulfilments keep their pickup status. For an order with no fulfilments yet, set `orders.pickup_location_id` to the default location's ID where its shipping line's `meta->pickup` or `meta->collect` is `true`, so its lines are still picked up when the fulfilments are created.

Pickup is only offered at a location with `accepts_pickup` set. Set it to `true` for the default location, and for any other location customers collect from, or pickup stops being offered. A custom `Lunar\Core\Contracts\FulfilmentMethod` adds `isAvailable(): bool`, returning `true` when it is always available.

`continue_selling` and `sell_against_incoming` replace `product_variants.selling_policy` and its `backorder` allowance. Map `always` to `continue_selling = true`, `in_stock` to `continue_selling = false`, and `in_stock_or_on_backorder` to `continue_selling = false` with `sell_against_incoming = true`. Selling beyond available stock now reads the tracked incoming bucket instead of the allowance, so for each `in_stock_or_on_backorder` variant with a positive `backorder`, add it to the `incoming` of the variant's `stock_levels` row at the default location and to `product_variants.stock_incoming`, creating the row with zeroes elsewhere when there is none. The `Lunar\Core\Enums\SellingPolicy` enum is removed.

## Folded migrations

These migrations shipped in an alpha and were later folded into the baseline. Their files no longer exist, but an application that ran them still has their rows in the `migrations` table.

| Migration | Folded into |
| - | - |
| `2026_01_01_000069_add_region_id_to_carts_and_orders` | `create_carts_table`, `create_orders_table` and `create_regions_table` |
| `2026_01_01_000070_drop_price_display_from_tax_zones` | `create_tax_zones_table` |
| `2026_07_16_000000_add_preferred_locale_to_staff_table` | `create_staff_table` |
| `2026_01_01_000055_create_cart_line_discount_table` | Removed. The table was never used; see `cart_line_discount` under 2.0.0-beta.1. |

The schema these migrations produced is unchanged, so an application that ran them needs no schema change. The leftover rows are harmless, but `php artisan migrate:rollback` reports them as not found. Delete them once the catch-up migration has run:

```php theme={null}
use Illuminate\Support\Facades\DB;

DB::table('migrations')->whereIn('migration', [
    '2026_01_01_000069_add_region_id_to_carts_and_orders',
    '2026_01_01_000070_drop_price_display_from_tax_zones',
    '2026_07_16_000000_add_preferred_locale_to_staff_table',
])->delete();
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.