Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken migration, STORED NULL is not valid on mariadb 10.4+ #51

Closed
okolvik-avento opened this issue Nov 9, 2024 · 4 comments
Closed
Assignees

Comments

@okolvik-avento
Copy link

The latest migration src/migrations/m240819_121818_loosen_aux_data_uniq.php does not successfully complete on mariadb 10.4+ (10.4.34 to be specific). This also affects the new Install.php script.

This is beacuse mariadb does not support the STORED NULL syntax.

execute SQL: ALTER TABLE {{%stripe_subscriptiondata}} ADD COLUMN [[latestInvoiceId]] VARCHAR(255) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(`data`, '$.\"latest_invoice\"'))) STORED NULL ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1
The SQL being executed was: ALTER TABLE `craft_stripe_subscriptiondata` ADD COLUMN `latestInvoiceId` VARCHAR(255) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(`data`, '$.\"latest_invoice\"'))) STORED NULL (/var/www/html/vendor/yiisoft/yii2/db/Schema.php:676)

Valid syntax for mysql:

col_name data_type [GENERATED ALWAYS] AS (expr)
  [VIRTUAL | STORED] [NOT NULL | NULL]
  [UNIQUE [KEY]] [[PRIMARY] KEY]
  [COMMENT 'string']

Valid syntax for mariadb:

<type>  [GENERATED ALWAYS]  AS   ( <expression> )
[VIRTUAL | PERSISTENT | STORED]  [UNIQUE] [UNIQUE KEY] [COMMENT <text>]

Note that STORED does not require NULL, as NULL is implied when not specified on generated columns.

@okolvik-avento okolvik-avento changed the title STORED NULL is not valid on mariadb 10.4+ Broken migration, STORED NULL is not valid on mariadb 10.4+ Nov 9, 2024
@CustomCodeIT
Copy link

I am experiencing this issue too.

I just tried a fresh install on:

  • Craft 5.4.10.1
  • MariaDB 10.11.9

execute SQL: ALTER TABLE {{%stripe_subscriptiondata}} ADD COLUMN latestInvoiceId VARCHAR(255) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(data, '$.\"latest_invoice\"'))) STORED NULL; ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1

@i-just
Copy link
Contributor

i-just commented Nov 11, 2024

Hi, thanks for reporting! I raised a PR for this.

@okolvik-avento
Copy link
Author

okolvik-avento commented Nov 19, 2024

Any chance the fix could be released soon?

@i-just
Copy link
Contributor

i-just commented Nov 20, 2024

Stripe 1.3.0 is out with a fix for that. Thanks again!

@i-just i-just closed this as completed Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants