このブログのコンテンツ管理にはStrapiを使っている。
Herokuの無料プランで動かしているのだけれども、インストールにはこちらのページ(多分公式)からワンクリックで簡単インストールした。ところが使っているうちに謎のエラーが出て記事の修正ができなくなってしまった。
なのでncuを使った所バージョンが3.1.0から3.4.1にアップデートできる事が判明。
正直怖かったけど、いざとなったらgitで元に戻せばいいや!と思い切って全パッケージをバージョンアップした。
yarn install
までは問題なかったのだけれども、yarn dvelop
でエラーが…
$ yarn develop
yarn run v1.22.10
$ strapi develop
[2021-01-12T04:30:47.630Z] debug ⛔️ Server wasn't able to start properly.
[2021-01-12T04:30:47.632Z] error Model "article" is using reserved attribute names "published_at".
-> Make sure you are not using a reserved name or overriding the defined timestamp attributes.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
なんか致命的な予感が...
Google先生に聞いても特に何も出てこなかったので、まずはローカルで動かせるように修正。
published_at
を全ファイル検索して、必要な所をpublished
に変更。とりあえずapi/article/models/article.settings.json
とseed/seed.js
の2ファイル.cache
.tmp
build
export
ディレクトリを全削除して、ローカルのDBデータを再構築するようにするyarn develop
で実行既存のデータを全削除するのに思い至らず少しハマったけど、これでローカルは問題なく動いた。記事の修正も問題なく、心なしが前のバージョンより動作が早い気がする。
Heroku
のデータベースを直接いぢくるそして勢いこのままHerokuにデプロイ...当然動かず。まぁ予想通り。
デプロイとビルド自体は問題なかったので、DBの問題と判断してPostgres
のテーブルを直接書き換え。
$ heroku pg:psql -a [アプリ名]
--> Connecting to [postgresqlサーバー名]
psql (13.1, server 12.5 (Ubuntu 12.5-1.pgdg16.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
=> alter table articles rename column published_at to published;
ALTER TABLE
=> quit
そして空のcommitをして再push
$ git commit -m "DB上のarticlesテーブルのpublished_atをpublishedに変更" --allow-empty
$ git push heroku master
master
と言うところが微妙に古さを感じる ^^;
これでエラーも解消し、無事動作するようになった!よかったねー(禰豆子風