Skip to content

Fix supabase default schema problems#29

Merged
t38miwa merged 3 commits into
mainfrom
fix-baseline-problem
Oct 22, 2025
Merged

Fix supabase default schema problems#29
t38miwa merged 3 commits into
mainfrom
fix-baseline-problem

Conversation

@t38miwa
Copy link
Copy Markdown
Owner

@t38miwa t38miwa commented Oct 22, 2025

概要

supabaseのデフォルトのスキーマが初期状態から存在するため、apply時にクリーンなDBを求めるatlasを使うとエラーが発生する。しかし、それらのテーブルは必要なため、atlasの管理対象から外し、publicスキーマのみを管理対象とすることで課題を解決した。

目的

supabaseのデフォルトのスキーマが初期状態から存在することによって起こるエラーを解決すること

やったこと

・atlas.hclの設定を変更
・cliからprod環境へマイグレーション実行
・ciが問題なく動作するかチェック
・workflow-dispatchが問題なく動作するかチェック

結果

prod環境でのapllyが問題なくできた。

atlas migrate apply --env production
Migrating to version 20251022061054 from 20251022055312 (1 migrations in total):

  -- migrating version 20251022061054
    -> CREATE TABLE "public"."posts" (
         "id" serial NOT NULL,
         "title" text NOT NULL,
         "content" text NULL,
         "user_id" integer NULL,
         "created_at" timestamp NULL DEFAULT CURRENT_TIMESTAMP,
         "updated_at" timestamp NULL DEFAULT CURRENT_TIMESTAMP,
         PRIMARY KEY ("id"),
         CONSTRAINT "posts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
       );
  -- ok (2.604085125s)

  -------------------------
  -- 8.906709292s
  -- 1 migration
  -- 1 sql statement
atlas migrate status --env production
Migration Status: OK
  -- Current Version: 20251022061054
  -- Next Version:    Already at latest version
  -- Executed Files:  2
  -- Pending Files:   0
atlas migrate status --env local
Migration Status: OK
  -- Current Version: 20251022061054
  -- Next Version:    Already at latest version
  -- Executed Files:  2
  -- Pending Files:   0

ciが問題なく動作するかチェック

問題なく動作することを確認
https://github.com/t38miwa/db-migration/actions/runs/18707441782

workflow-dispatchが問題なく動作するかチェック

問題なく動作することを確認
https://github.com/t38miwa/db-migration/actions/runs/18707552787

@t38miwa t38miwa linked an issue Oct 22, 2025 that may be closed by this pull request
@t38miwa t38miwa merged commit 5517fcb into main Oct 22, 2025
2 checks passed
@t38miwa t38miwa deleted the fix-baseline-problem branch October 22, 2025 06:30
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.

first migration not gonna work becuase of supabase default schema

1 participant