Skip to content

Conversation

@rakuda-san-desu
Copy link
Contributor

@rakuda-san-desu rakuda-san-desu commented Dec 12, 2025

close: #1770

やったこと

migrate_adding_id_to_yaml を実行したとき、id と一緒に created_at も書き出すよう修正しました🛠️

メモ:
YAML 内の既存の記述に影響を与えない(記載内容の並び順を既存と揃える)ため 、new_dojo['order'] = d.order のコメントアウトを解除しています!

確認したこと

  • タスクを実行するとidcreated_at が書き出される
  • 更新箇所以外に既存のrakeタスクの動作に影響がない

確認方法

  1. db/dojos.yml に以下のサンプルを入力
    - order: '011002'
      name: サンプル
      prefecture_id: 1
      logo: "/img/dojos/default.webp"
      url: https://example.com/
      description: 札幌市で月2回開催
      tags:
      - Scratch
      - micro:bit
      - Arduino
      - ラズベリーパイ
      - 電子工作
    
  2. $ bundle exec rails dojos:update_db_by_yaml を実行
  3. $ bundle exec rails dojos:migrate_adding_id_to_yaml を実行
  4. idcreated_at が書き出される
    - id: 349
      order: '011002'
      name: サンプル
      prefecture_id: 1
      logo: "/img/dojos/default.webp"
      url: https://example.com/
      description: 札幌市で月2回開催
      tags:
      - Scratch
      - micro:bit
      - Arduino
      - ラズベリーパイ
      - 電子工作
    
  5. 不要な更新がない
    スクリーンショット 2025-12-12 18 15 07

MEMO: 確認後、サンプルで作成されたデータは削除しておく

new_dojo = {}
new_dojo['id'] = d.id
#new_dojo['order'] = d.order # ID の直後に固定させる場合の例
new_dojo['order'] = d.order
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今回の title/description を読む限りではココのコメントアウトの解除は不要そうかなと思いましたが、もし何か解除した理由などあれば description に記載いただけると助かります...!! 🙏 ✨

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yasulab コメントありがとうございます!

YAML 内の既存の記述に影響を与えない(記載内容の並び順を既存と揃える)ため 、new_dojo['order'] = d.order のコメントアウトを解除しています。

もし、既存の記載内容の並び順が変わってしまっても問題ないようでしたら、2. のようにコメントアウトを解除しない方が、記述もその後の処理もスッキリしそうと感じたのですが、どちらが良さそうでしょうか 👀💭

  1. new_dojo['order'] = d.order のコメントアウトを解除する
    • YAMLの記載は既存の並び順の通り
      • id
      • order
      • created_at
      • ...
  2. new_dojo['order'] = d.order のコメントアウトを解除しない
    • YAMLの記載順は以下になる
      • id
      • created_at
      • order
      • ...
    • 既存の記述も記載順が入れ替わる(内容は変わらない

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakuda-san-desu なるほどです! 理由がどこにも記載されておらずコメント解除のみ行われていた点 が気になった部分ですので、であればその理由を description に記載していただけると助かります! (>人< )✨

Copy link
Contributor Author

@rakuda-san-desu rakuda-san-desu Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description に追記しました!
今後も理由まで記載するようにしていきます📝

ご確認ありがとうございます🙏✨

@nacchan99
Copy link
Contributor

タスクを実行すると、idcreated_at が書き出されることを確認しました◎
ご対応ありがとうございます 🙏✨

🔽 出力結果

- id: 349
  order: '011002'
  created_at: '2025-12-16'
  name: サンプル
  prefecture_id: 1
  logo: "/img/dojos/default.webp"
  url: https://example.com/
  description: 札幌市で月2回開催
  tags:
  - Scratch
  - micro:bit
  - Arduino
  - ラズベリーパイ
  - 電子工作

@rakuda-san-desu
Copy link
Contributor Author

@nacchan99 動作確認ありがとうございます🙏✨

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

Successfully merging this pull request may close these issues.

coderdojo.jp の Dojo 情報入力で created_at の入力ミスに対応したい

4 participants