LoginSignup
1
0

はじめに

Flutter × Supabaseのアプリ開発を進める中で、なぜか微妙にローカルで作業したものをリモートに反映するのに苦戦をしてしまったのでコマンドのメモを残します。

Supabaseドキュメント

今回このページを見つけるのに苦労をしてしまいました。

結論から言うと、以下のコマンドで解決です

# プロジェクトとリンク
supabase link
# ローカルの状態からマイグレーションファイルを生成
supabase db diff --use-migra -f {任意の名前}
# (例) supabase db diff --use-migra -f create_users_table

# リモートに反映する
supabase db push

忘れてはいけないSupabaseのAI機能

supabaseはプロジェクトのサイドバーの一番下に検索アイコンがあります。
この機能をすっかり忘れていました。

スクリーンショット 2024-06-15 1.52.53.png

まず、手元のターミナルでsupabase db --helpをしたところ以下が表示されました。

% supabase db --help                               
Manage Postgres databases

Usage:
  supabase db [command]

Available Commands:
  diff        Diffs the local database for schema changes
  dump        Dumps data or schemas from the remote database
  lint        Checks local database for typing error
  pull        Pull schema from the remote database
  push        Push new migrations to the remote database
  reset       Resets the local database to current migrations
  start       Starts local Postgres database

Flags:
  -h, --help   help for db

Global Flags:
      --create-ticket                     create a support ticket for any CLI error
      --debug                             output debug logs to stderr
      --dns-resolver [ native | https ]   lookup domain names using the specified resolver (default native)
      --experimental                      enable experimental features
      --workdir string                    path to a Supabase project directory

Use "supabase db [command] --help" for more information about a command.

記載の通り、diffコマンドで実現できそうです。

diff        Diffs the local database for schema changes

と、そこまでわかったら検索するのですが、Supabaseの検索はAI検索のため類似情報をいくつかピックアップしてくれます。しかし、今回は一番先頭にありました(そこまで見抜かれてる...?)

スクリーンショット 2024-06-15 1.56.24.png

そして冒頭のドキュメントに到達できて無事ローカルからリモートへ反映ができました。

以上、小ネタの備忘録でした。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0