Skip to content

Migration 000019_add_generated_columns_and_indexes_to_key_value failing on empty database #1248

@ryanvade

Description

@ryanvade

I'm running the migrations for the first time and am getting the following error:

1/u create-key-value-table (27.648338ms)
2/u add-sites-table (52.171012ms)
3/u add-accounts-table (77.492294ms)
4/u add-users-table (105.248162ms)
5/u add-follows-table (130.493933ms)
6/u add-collections-columns-to-accounts-table (168.815055ms)
7/u add-posts-table (197.42862ms)
8/u add-likes-table (228.196151ms)
9/u add-reposts-table (254.14759ms)
10/u add-feeds-table (293.9016ms)
11/u add-unique-constraint-to-feeds (324.574267ms)
12/u add-uuid-to-accounts (345.610751ms)
13/u remove-duplicate-articles (342.05007ms)
14/u remove-replies-in-feed (328.226221ms)
15/u add-attachments-to-posts (355.134747ms)
16/u add-deleted-column-to-posts (386.955799ms)
17/u drop_deleted_column_from_posts (396.758782ms)
18/u add_deleted_at_column_to_posts (415.5996ms)
error: migration failed in line 0: ALTER TABLE key_value
    ADD COLUMN object_id VARCHAR(150)
    GENERATED ALWAYS AS (
        CASE
            WHEN REGEXP_LIKE(JSON_UNQUOTE(value->>"$.object.id"), '^https')
            THEN JSON_UNQUOTE(value->>"$.object.id")
            ELSE ''
        END) STORED;

CREATE INDEX idx_object_id ON key_value(object_id);

ALTER TABLE key_value
    ADD COLUMN object_in_reply_to VARCHAR(150)
    GENERATED ALWAYS AS (
        CASE
            WHEN REGEXP_LIKE(JSON_UNQUOTE(value->>"$.object.inReplyTo"), '^https')
            THEN JSON_UNQUOTE(value->>"$.object.inReplyTo")
        ELSE ''
        END) STORED;

CREATE INDEX idx_object_in_reply_to ON key_value(object_in_reply_to);
 (details: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"$.object.id"), '^https')
            THEN JSON_UNQUOTE(value->>"$.object.id")
 ' at line 5)

Using the container: ghcr.io/tryghost/activitypub-migrations:1.1.0@sha256:b3ab20f55d66eb79090130ff91b57fe93f8a4254b446c2c7fa4507535f503662

This is on MySQL 8 hosted by DigitalOcean, version 8.0.35.

Is this a database version issue or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions